Repository navigation
fix(ingest): extract equations during ingest, derive schema evolution - #580
Merged
Merged
Conversation
No ingest driver called the equation extractor, so a corpus built the normal way had no equations table and find_equation always fell back to dense_only_fallback. ingest_one_paper now extracts a paper's equations from the HTML it chunked, right after writing the chunks, and bulk ingest and the OAI delta build the equation trees once at the end of a run, under the run's dataset write lock. Notebook ingest runs through bulk ingest. Each equation is linked to the chunk whose body holds every cell of it as the chunker writes it ($alttext$), preferring a statement chunk. Without that link the chunks-proxy dense step finds no candidate, so the trees alone would not have reached ted_fused. The tree indexer is a no-op on a dataset with no equations table, and its CLI refuses a missing dataset path. Closes #550
Schema evolution was a hand-kept SQL-default map in ingest.store that failed on any column it did not list, reached only the chunks table, and left equation trees unmarked, so a tree from an older MathML normalizer could never be re-indexed by a plain run. ingest.schema.add_missing_columns now derives every addition from the table's Arrow schema: a nullable column gets NULL, and a column whose pre-existing rows hold a known value (source_kind and license on chunks) takes it from PRE_COLUMN_VALUES. A required column with no such value is refused before the table changes, with SchemaEvolutionError. The chunks writer, the equations table and the definitions table all evolve through it when a writer opens them. The equations schema gains normalizer_version. The tree indexer stamps it and rebuilds any tree whose version differs from the running normalizer's, including trees from before the column existed, so after a normalizer change the next ingest run (or a plain index_equations) brings the table in line. Closes #315
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two equation findings: ingest never extracted equations, and schema evolution only knew the columns it listed by hand.
#550: extract equations during ingest
find_equationalways fell back todense_only_fallback.ingest_one_papernow extracts a paper's equations from the HTML it chunked, right after writing the chunks.ted_fused.#315: derive schema evolution from the schema
ingest.store:ingest.schema.add_missing_columnsnow derives every addition from the table's Arrow schema:source_kindandlicenseon chunks) takes it fromPRE_COLUMN_VALUES;SchemaEvolutionErrorbefore the table changes.normalizer_version. The tree indexer stamps it and rebuilds any tree whose version differs from the running normalizer's, including trees from before the column existed. After a normalizer change, the next ingest run or a plainindex_equationsbrings the table in line.Closes #550
Closes #315
Verification
ruff check .is clean.7cc5620: 5610 passed, 182 skipped, 1 xfailed.make wheel-checkpasses on that merge.The wiki's ingest pages should say that equations are now extracted during ingest and rebuilt after a normalizer change.