Skip to content

Commit

Permalink
feat(accuracy_tests): print nice table summary
Browse files Browse the repository at this point in the history
  • Loading branch information
Elijas committed Dec 21, 2023
1 parent a76fdb8 commit 03b1afe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/accuracy/structure_and_text/summarize_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def main():
), f"missing '{report.actual_structure_and_text_summary.name}' for '{report.identifier}'"
with report.actual_structure_and_text_summary.open("r") as file:
summary_data = json.load(file)
metrics = summary_data["metrics"]
metrics = summary_data["metrics"].copy()
metrics["identifier"] = report.identifier
all_metrics.append(metrics)

# STEP: Aggregate the metrics
Expand Down Expand Up @@ -92,7 +93,11 @@ def main():
summary["total_unexpected"][element_type] += count

# STEP: Show and save the summary
print("# Selected filings:", [r.identifier for r in filings])
print("# Selected filings | F1-score | Recall | Precision")
for m in all_metrics:
print(
f"{m['identifier']:>33} | {m['f1_score']:>8} | {m['recall']:>7} | {m['precision']:>7}"
)
print(
"# Summary:",
json.dumps(summary, indent=4, sort_keys=False, ensure_ascii=False),
Expand Down

0 comments on commit 03b1afe

Please sign in to comment.