Files
docling-eval/tests/test_utils.py
a34f2649ab fix: update hyperscalers to support multiple image file types (#118)
* fix: update docling prediction provider to include word cells

Signed-off-by: samiullahchattha <Sami.Ullah1@ibm.com>

* fix: missing parsed_page in set_word_cells method

Signed-off-by: samiullahchattha <Sami.Ullah1@ibm.com>

* Update docling_eval/prediction_providers/docling_provider.py

Co-authored-by: Christoph Auer <60343111+cau-git@users.noreply.github.com>
Signed-off-by: samiuc <sami.ullah.chat@gmail.com>

* Update docling_eval/prediction_providers/docling_provider.py

Co-authored-by: Christoph Auer <60343111+cau-git@users.noreply.github.com>
Signed-off-by: samiuc <sami.ullah.chat@gmail.com>

* fix: conditionally populate word_cells in _set_word_cells method

Signed-off-by: samiullahchattha <Sami.Ullah1@ibm.com>

* feat: Implement smart weighted character distribution for line text processing

Signed-off-by: samiullahchattha <Sami.Ullah1@ibm.com>

* fix: remove redundant field validators

Signed-off-by: samiullahchattha <Sami.Ullah1@ibm.com>

* refactor: replace BoundingBoxDict with BoundingBox

Signed-off-by: samiullahchattha <Sami.Ullah1@ibm.com>

* refactor: update BoundingBox usage in prediction providers

Signed-off-by: samiullahchattha <Sami.Ullah1@ibm.com>

* refactor: remove unused code

Signed-off-by: samiullahchattha <Sami.Ullah1@ibm.com>

* refactor: move validate_evaluation_results to test_utils

Signed-off-by: samiullahchattha <Sami.Ullah1@ibm.com>

---------

Signed-off-by: samiullahchattha <Sami.Ullah1@ibm.com>
Signed-off-by: samiuc <sami.ullah.chat@gmail.com>
Co-authored-by: samiullahchattha <Sami.Ullah1@ibm.com>
Co-authored-by: Christoph Auer <60343111+cau-git@users.noreply.github.com>
2025-07-01 12:17:50 -07:00

37 lines
1.1 KiB
Python

import json
from pathlib import Path
from docling_eval.evaluators.ocr.evaluation_models import OcrDatasetEvaluationResult
def validate_evaluation_results(
target_path: Path,
benchmark: str,
modality: str,
evaluation_type: str = "ocr",
) -> OcrDatasetEvaluationResult:
eval_json_filename = f"evaluation_{benchmark}_{modality}.json"
eval_json_path = target_path / "evaluations" / evaluation_type / eval_json_filename
assert eval_json_path.exists(), f"Evaluation JSON file not found: {eval_json_path}"
with open(eval_json_path, "r") as f:
result = json.load(f)
assert result is not None, "Evaluation JSON file is empty or invalid."
assert result, "Overall metrics not found in evaluation results."
metrics = OcrDatasetEvaluationResult(**result)
assert (
metrics.f1_score > 0
), f"F1 score ({metrics.f1_score}) must be greater than 0."
assert (
metrics.precision > 0
), f"Precision score ({metrics.precision}) must be greater than 0."
assert (
metrics.recall > 0
), f"Recall score ({metrics.recall}) must be greater than 0."
return metrics