Skip to content

Table record match: read row-scoped section labels as body rows - #5

Merged
olihou merged 1 commit into
mainfrom
oli/xt-633-table-row-scope-labels
Nov 4, 2026
Merged

olihou merged 1 commit into
mainfrom
oli/xt-633-table-row-scope-labels

Conversation

@olihou

@olihou olihou commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

A table row made only of row-scoped headers, such as the full-width section label <th colspan="3" scope="rowgroup">Assets</th>, now counts as a body row in table record matching. Its text no longer drops out of the records.

Why

parse_html_tables correctly leaves a <th scope="row|rowgroup"> cell out of col_headers. But find_col_header_rows still counted any body row holding a <th> as part of the column-header block. The title detector only looks at col_headers, so the row was neither a column key nor a record, and its text was lost. The same markup without scope (or with <td>) kept its text, so the correct accessibility attribute cost content.

Change

_declares_row_headers_only in table_title_stripping.py: a body row whose <th> cells all declare a row scope ends the header scan. This mirrors the existing handling of <th> row labels in a label column. Unchanged: rows inside <thead>, rows mixing row and column scopes, and markup without scope. The scope attribute is not stripped, because chart label lookups use it.

Cherry-picked from etienne/grader-ignore-scope (1181984) onto current main. Etienne remains the commit author.

Testing

  • uv run ruff check src tests and uv run ruff format --check src tests pass.
  • uv run pytest -q: 5,153 passed.
  • test_table_row_scope_label.py: 13 tests; 9 of them fail without the fix.

Effect

Re-grading the stored Nutrient DWS (Agentic) table outputs from the 2026-10-29 measurement (503 pages, no new API calls):

Without fix With fix
Tables 86.078 86.115

5 pages change. 4 go up (Low-Back-Guideline (1)_page2 0.777 → 0.944, Apple 10-k_page3 0.939 → 0.952, 0000027_page1 0.747 → 0.754, FBLB-134215544_page15 0.973 → 0.979) and 1 goes down slightly (SERFF_TX_random_pages 1_page857 0.438 → 0.434). Any provider that writes row-scoped <th> cells in body rows is affected the same way.

The same commit goes upstream in run-llama#250, together with the Nutrient DWS row refresh.

A full-width section label written <th colspan="n" scope="rowgroup"> (or
scope="row") lost its record. The parser rightly keeps a row-scoped header
out of col_headers, but the header-block scanner still counted the row as a
column-header row because it holds a <th>. With no column-header text, the
title detector could not see it as a spanning title either, so the row was
neither a column key nor a data row and its text dropped out of the records.
The same markup without scope, or with <td>, kept the record.

find_col_header_rows now stops at a body row whose <th> cells all declare a
row scope, as it already does for rows whose <th> cells sit only in row-header
columns. Rows inside <thead>, rows mixing row- and column-scoped headers, and
markup without scope are unchanged.
@olihou
olihou merged commit 0e90030 into main Nov 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants