Skip to content

Add keep_tables option to keep tables in the article text - #67

Merged
jdkent merged 1 commit into
neurosynth:masterfrom
jdkent:enh/keep_tables
Oct 2, 2026
Merged

jdkent merged 1 commit into
neurosynth:masterfrom
jdkent:enh/keep_tables

Conversation

@jdkent

@jdkent jdkent commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Readability keeps only paragraphs and headings, so every table was dropped from Article.text.

With parse_article(..., keep_tables=True), each innermost table is swapped for a placeholder before cleaning and replaced afterwards by its rows: the caption, then one tab-separated line per row, with spanned cells repeated as pandas.read_html does. A table whose placeholder readability discarded is appended at the end, unless an identical table was already placed. The default is unchanged.

table_text is public, so callers can render tables ACE fetched from linked pages in the same way.

Measured on 200 ns-pond articles: the share whose text holds a coordinate row rose from 9% to 76%. Every remaining miss is a table that is not in the page HTML. No article lost body text compared with keep_tables=False.

The 14 tests that fail in test_ace.py also fail on master (encoding errors and network cassettes). The three new tests pass.

🤖 Generated with Claude Code

Readability keeps only paragraphs and headings, so every table was
dropped from Article.text. With keep_tables=True each innermost table is
swapped for a placeholder before cleaning and replaced by its rows
afterwards (caption, then one tab-separated line per row, spanned cells
repeated). A table whose placeholder readability discarded is appended
at the end. table_text is public so callers can render tables ACE
fetched from linked pages the same way.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@jdkent jdkent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jdkent
jdkent merged commit 19b6340 into neurosynth:master Oct 2, 2026
1 check 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.

1 participant