Skip to content

Commit

Permalink
fix: Protect the prediction in TableEvaluator within try..except
Browse files Browse the repository at this point in the history
Signed-off-by: Nikos Livathinos <[email protected]>
  • Loading branch information
nikos-livathinos committed Mar 6, 2025
1 parent fa3eba6 commit f7b2c67
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions docling_eval/evaluators/table_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def __call__(

table_evaluations = []
table_struct_evaluations = []
evaluation_errors = 0
for i, data in tqdm(
enumerate(ds_selection),
desc="Table evaluations",
Expand All @@ -148,21 +149,30 @@ def __call__(
continue
pred_doc = pred_dict[doc_id]

results = self._evaluate_tables_in_documents(
doc_id=data[BenchMarkColumns.DOC_ID],
true_doc=gt_doc,
pred_doc=pred_doc,
structure_only=False,
)
table_evaluations.extend(results)

results = self._evaluate_tables_in_documents(
doc_id=data[BenchMarkColumns.DOC_ID],
true_doc=gt_doc,
pred_doc=pred_doc,
structure_only=True,
)
table_struct_evaluations.extend(results)
try:
results = self._evaluate_tables_in_documents(
doc_id=data[BenchMarkColumns.DOC_ID],
true_doc=gt_doc,
pred_doc=pred_doc,
structure_only=False,
)
table_evaluations.extend(results)

results = self._evaluate_tables_in_documents(
doc_id=data[BenchMarkColumns.DOC_ID],
true_doc=gt_doc,
pred_doc=pred_doc,
structure_only=True,
)
table_struct_evaluations.extend(results)
except Exception as ex:
evaluation_errors += 1
_log.error("Error during tables evaluation for %s", doc_id)

_log.info(
"Finish. %s documents were skipped due to evaluation errors",
evaluation_errors,
)

# Compute TED statistics for the entire dataset
teds_simple = []
Expand Down

0 comments on commit f7b2c67

Please sign in to comment.