From c25e9cb084bfb6e8f19a0ef86b2229769cb7c8e0 Mon Sep 17 00:00:00 2001 From: Jake Poznanski Date: Wed, 19 Mar 2025 18:57:00 +0000 Subject: [PATCH] Addxing some fixes --- olmocr/bench/benchmark.py | 1 + olmocr/bench/test_tests.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/olmocr/bench/benchmark.py b/olmocr/bench/benchmark.py index 9fd1737..1abc3dc 100644 --- a/olmocr/bench/benchmark.py +++ b/olmocr/bench/benchmark.py @@ -306,6 +306,7 @@ def main(): half_width = ((ci[1] - ci[0]) / 2) * 100 ciw_str = f"± {half_width:0.1f}%" print(f"{candidate_name:20s} : Average Score: {status} {ciw_str}") + test_type_breakdown.sort(key=lambda f: f[0]) for ttype, scores in test_type_breakdown.items(): avg = sum(scores) / len(scores) * 100 if scores else 0.0 print(f" {ttype:8s}: {avg:0.1f}% average pass rate over {len(scores)} tests") diff --git a/olmocr/bench/test_tests.py b/olmocr/bench/test_tests.py index 89993ae..61f59b8 100644 --- a/olmocr/bench/test_tests.py +++ b/olmocr/bench/test_tests.py @@ -572,6 +572,25 @@ Some text before the table. result, explanation = test.run(table) self.assertTrue(result, explanation) + def test_big_table(self): + # TODO this would work with html tables with a rowspan? + table = """| Question - – Satisfaction on scale of 10 | Response | Resident Sample | Business Sample | +|----------------------------------------|----------|----------------|-----------------| +| Planning for and managing residential, commercial and industrial development | Rating of 8, 9 or 10 | 13% | 11% | +| | Average rating | 6.4 | 5.7 | +| | Don’t know responses | 11% | 6% | +| Environmental protection, support for green projects (e.g. green grants, building retrofits programs, zero waste) | Rating of 8, 9 or 10 | 35% | 34% | +| | Average rating | 8.0 | 7.5 | +| | Don’t know responses | 8% | 6% | +| Providing and maintaining parks and green spaces | Rating of 8, 9 or 10 | 42% | 41% | +| | Average rating | 7.7 | 7.3 | +| | Don’t know responses | 1% | 1% | + +Base: Resident respondents (n=1,315) and Business respondents (n=397) +""" + test = TableTest(pdf="test.pdf", page=1, id="test_id", type=TestType.TABLE.value, cell="Planning for and managing residential, commercial and industrial development", down="Environmental protection,\nsupport for green projects\n(e.g. green grants,\nbuilding retrofits programs,\nzero waste)") + result, explanation = test.run(table) + self.assertTrue(result, explanation) class TestBaselineTest(unittest.TestCase): """Test the BaselineTest class"""