11import argparse
22import json
33from pathlib import Path
4+
45from dotenv import load_dotenv
56
67from graphgen .models import KGQualityEvaluator
@@ -37,14 +38,22 @@ def _print_accuracy_summary(acc):
3738 precision = e .get ("precision" , {})
3839
3940 print (" Entity Extraction Quality:" )
40- print (f" Overall Score: { overall .get ('mean' , 0 ):.3f} (mean), "
41- f"{ overall .get ('median' , 0 ):.3f} (median)" )
42- print (f" Accuracy: { accuracy .get ('mean' , 0 ):.3f} (mean), "
43- f"{ accuracy .get ('median' , 0 ):.3f} (median)" )
44- print (f" Completeness: { completeness .get ('mean' , 0 ):.3f} (mean), "
45- f"{ completeness .get ('median' , 0 ):.3f} (median)" )
46- print (f" Precision: { precision .get ('mean' , 0 ):.3f} (mean), "
47- f"{ precision .get ('median' , 0 ):.3f} (median)" )
41+ print (
42+ f" Overall Score: { overall .get ('mean' , 0 ):.3f} (mean), "
43+ f"{ overall .get ('median' , 0 ):.3f} (median)"
44+ )
45+ print (
46+ f" Accuracy: { accuracy .get ('mean' , 0 ):.3f} (mean), "
47+ f"{ accuracy .get ('median' , 0 ):.3f} (median)"
48+ )
49+ print (
50+ f" Completeness: { completeness .get ('mean' , 0 ):.3f} (mean), "
51+ f"{ completeness .get ('median' , 0 ):.3f} (median)"
52+ )
53+ print (
54+ f" Precision: { precision .get ('mean' , 0 ):.3f} (mean), "
55+ f"{ precision .get ('median' , 0 ):.3f} (median)"
56+ )
4857 print (f" Total Chunks Evaluated: { e .get ('total_chunks' , 0 )} " )
4958
5059 if "relation_accuracy" in acc :
@@ -55,14 +64,22 @@ def _print_accuracy_summary(acc):
5564 precision = r .get ("precision" , {})
5665
5766 print (" Relation Extraction Quality:" )
58- print (f" Overall Score: { overall .get ('mean' , 0 ):.3f} (mean), "
59- f"{ overall .get ('median' , 0 ):.3f} (median)" )
60- print (f" Accuracy: { accuracy .get ('mean' , 0 ):.3f} (mean), "
61- f"{ accuracy .get ('median' , 0 ):.3f} (median)" )
62- print (f" Completeness: { completeness .get ('mean' , 0 ):.3f} (mean), "
63- f"{ completeness .get ('median' , 0 ):.3f} (median)" )
64- print (f" Precision: { precision .get ('mean' , 0 ):.3f} (mean), "
65- f"{ precision .get ('median' , 0 ):.3f} (median)" )
67+ print (
68+ f" Overall Score: { overall .get ('mean' , 0 ):.3f} (mean), "
69+ f"{ overall .get ('median' , 0 ):.3f} (median)"
70+ )
71+ print (
72+ f" Accuracy: { accuracy .get ('mean' , 0 ):.3f} (mean), "
73+ f"{ accuracy .get ('median' , 0 ):.3f} (median)"
74+ )
75+ print (
76+ f" Completeness: { completeness .get ('mean' , 0 ):.3f} (mean), "
77+ f"{ completeness .get ('median' , 0 ):.3f} (median)"
78+ )
79+ print (
80+ f" Precision: { precision .get ('mean' , 0 ):.3f} (mean), "
81+ f"{ precision .get ('median' , 0 ):.3f} (median)"
82+ )
6683 print (f" Total Chunks Evaluated: { r .get ('total_chunks' , 0 )} " )
6784 else :
6885 print (f"\n [Accuracy] Error: { acc ['error' ]} " )
@@ -73,19 +90,25 @@ def _print_consistency_summary(cons):
7390 if "error" not in cons :
7491 print ("\n [Consistency]" )
7592 print (f" Conflict Rate: { cons .get ('conflict_rate' , 0 ):.3f} " )
76- print (f" Conflict Entities: { cons .get ('conflict_entities_count' , 0 )} / "
77- f"{ cons .get ('total_entities' , 0 )} " )
78- entities_checked = cons .get ('entities_checked' , 0 )
93+ print (
94+ f" Conflict Entities: { cons .get ('conflict_entities_count' , 0 )} / "
95+ f"{ cons .get ('total_entities' , 0 )} "
96+ )
97+ entities_checked = cons .get ("entities_checked" , 0 )
7998 if entities_checked > 0 :
80- print (f" Entities Checked: { entities_checked } (entities with multiple sources)" )
81- conflicts = cons .get ('conflicts' , [])
99+ print (
100+ f" Entities Checked: { entities_checked } (entities with multiple sources)"
101+ )
102+ conflicts = cons .get ("conflicts" , [])
82103 if conflicts :
83104 print (f" Total Conflicts Found: { len (conflicts )} " )
84105 # Show sample conflicts
85106 sample_conflicts = conflicts [:3 ]
86107 for conflict in sample_conflicts :
87- print (f" - { conflict .get ('entity_id' , 'N/A' )} : { conflict .get ('conflict_type' , 'N/A' )} "
88- f"(severity: { conflict .get ('conflict_severity' , 0 ):.2f} )" )
108+ print (
109+ f" - { conflict .get ('entity_id' , 'N/A' )} : { conflict .get ('conflict_type' , 'N/A' )} "
110+ f"(severity: { conflict .get ('conflict_severity' , 0 ):.2f} )"
111+ )
89112 else :
90113 print (f"\n [Consistency] Error: { cons ['error' ]} " )
91114
@@ -103,15 +126,19 @@ def _print_structure_summary(struct):
103126 noise_check = thresholds .get ("noise_ratio" , {})
104127 noise_threshold = noise_check .get ("threshold" , "N/A" )
105128 noise_pass = noise_check .get ("pass" , False )
106- print (f" Noise Ratio: { struct .get ('noise_ratio' , 0 ):.3f} "
107- f"({ '✓' if noise_pass else '✗' } < { noise_threshold } )" )
129+ print (
130+ f" Noise Ratio: { struct .get ('noise_ratio' , 0 ):.3f} "
131+ f"({ '✓' if noise_pass else '✗' } < { noise_threshold } )"
132+ )
108133
109134 # Largest CC Ratio
110135 lcc_check = thresholds .get ("largest_cc_ratio" , {})
111136 lcc_threshold = lcc_check .get ("threshold" , "N/A" )
112137 lcc_pass = lcc_check .get ("pass" , False )
113- print (f" Largest CC Ratio: { struct .get ('largest_cc_ratio' , 0 ):.3f} "
114- f"({ '✓' if lcc_pass else '✗' } > { lcc_threshold } )" )
138+ print (
139+ f" Largest CC Ratio: { struct .get ('largest_cc_ratio' , 0 ):.3f} "
140+ f"({ '✓' if lcc_pass else '✗' } > { lcc_threshold } )"
141+ )
115142
116143 # Avg Degree
117144 avg_degree_check = thresholds .get ("avg_degree" , {})
@@ -122,16 +149,20 @@ def _print_structure_summary(struct):
122149 threshold_str = f"{ avg_degree_threshold [0 ]} -{ avg_degree_threshold [1 ]} "
123150 else :
124151 threshold_str = str (avg_degree_threshold )
125- print (f" Avg Degree: { struct .get ('avg_degree' , 0 ):.2f} "
126- f"({ '✓' if avg_degree_pass else '✗' } { threshold_str } )" )
152+ print (
153+ f" Avg Degree: { struct .get ('avg_degree' , 0 ):.2f} "
154+ f"({ '✓' if avg_degree_pass else '✗' } { threshold_str } )"
155+ )
127156
128157 # Power Law R²
129- if struct .get (' powerlaw_r2' ) is not None :
158+ if struct .get (" powerlaw_r2" ) is not None :
130159 powerlaw_check = thresholds .get ("powerlaw_r2" , {})
131160 powerlaw_threshold = powerlaw_check .get ("threshold" , "N/A" )
132161 powerlaw_pass = powerlaw_check .get ("pass" , False )
133- print (f" Power Law R²: { struct .get ('powerlaw_r2' , 0 ):.3f} "
134- f"({ '✓' if powerlaw_pass else '✗' } > { powerlaw_threshold } )" )
162+ print (
163+ f" Power Law R²: { struct .get ('powerlaw_r2' , 0 ):.3f} "
164+ f"({ '✓' if powerlaw_pass else '✗' } > { powerlaw_threshold } )"
165+ )
135166 else :
136167 print (f"\n [Structural Robustness] Error: { struct ['error' ]} " )
137168
0 commit comments