Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Milestone 2 - Hierarchical Parsing and Standardization

This milestone turns the raw LaTeX corpus of Milestone 1 into structured data: every version of every paper is parsed into a hierarchy, its content is cleaned and normalized, its bibliography is converted to BibTeX, and identical references and elements are deduplicated across versions. All numbers below are computed from the parse results when the book is built.

1. Pipeline

python -m introds parse processes the corpus paper by paper, in parallel worker processes, and records the outcome of every version in SQLite so an interrupted run resumes where it stopped.

version folder ──► 1. multi-file gathering (root, \input / \include, comments)
                ──► 2. standardization (math normalization, formatting cleanup)
                ──► 3. hierarchy construction (headings, lists, sentences, formulas, figures)
                ──► 4. bibliography (.bib, \bibitem, .bbl) ──► BibTeX entries
paper (all versions) ──► 5. reference deduplication (one key per reference, \cite renamed)
                     ──► 6. element deduplication (identical cleaned content shares one ID)
                     ──► elements / hierarchy / bibtex
Source
Loading...

2. Multi-file gathering

  • Root. The publication root is the .tex file containing \documentclass. When several files declare one (standalone figures, templates), the root is the one with a \begin{document}, then a conventional name (main.tex, ms.tex, ...), then the most \inputs.

  • Compilation path. \input, \include, \subfile and \import are followed transitively, relative to the root folder (as LaTeX does) and to the including file. Include cycles and missing files are skipped. Every other .tex file in the folder is a redundant auxiliary file and is ignored.

  • Comments. % ... comments (but not \%), comment environments and \iffalse ... \fi blocks are removed before anything else, so a commented-out \input is plain text and never followed.

Source
Loading...
<Figure size 770x396 with 1 Axes>

3. Hierarchy construction

  • Levels. The document is the root. Sectioning commands (\part > \chapter > \section > \subsection > \subsubsection > \paragraph > \subparagraph) get their level from the commands the paper actually uses: in a paper without chapters, sections are the second level.

  • Leaves. Prose becomes sentences; equation blocks become formulas; floats (figure, table, algorithm, code listings, standalone tabular) become figures.

  • Lists. An itemize (also enumerate and description) is a list component whose items are the next level; an item contains sentences, formulas or nested lists.

  • Included / excluded. The abstract, acknowledgements (section or environment) and appendices (\appendix, including unnumbered \section*) are part of the tree. The references section (thebibliography, \bibliography, or a heading titled References / Bibliography) is not.

  • Sentences end at ., ! or ? followed by a new sentence, never inside math, commands (\cite{a.b}), URLs, decimal numbers or abbreviations such as e.g., i.e., et al., Fig. 1.

Source
Loading...
Loading...
Source
<Figure size 770x396 with 1 Axes>
Loading...

4. Standardization

  • Cleanup. Formatting without semantic meaning is removed: \centering, float placement options ([htpb]), table rules (\toprule, \midrule, ...), spacing (\vspace, \hspace), font size and style switches, \label, title-page metadata (\author, \affiliation, ...), colour commands and \makeatletter macro code. Emphasis wrappers keep their text (\textbf{x} → x).

  • Inline math \( ... \) and \begin{math} become $ ... $.

  • Block math $$ ... $$, \[ ... \], equation*, displaymath become \begin{equation} ... \end{equation}; multi-line environments keep their alignment inside it (align → \begin{equation}\begin{aligned} ... \end{aligned}\end{equation}), so the result is still valid LaTeX. \label, \nonumber and \notag are dropped.

\begin{align*} a &= b \\ c &= d \end{align*}   →   \begin{equation}\begin{aligned}a &= b \\ c &= d\end{aligned}\end{equation}
\[ E = mc^2 \]                                  →   \begin{equation}E = mc^2\end{equation}
\( x_i \)                                       →   $x_i$

5. References

Each version’s bibliography comes from, in this order:

  1. the .bib files named by \bibliography{...} / \addbibresource{...}, keeping only the entries actually cited (as BibTeX does), unless \nocite{*};

  2. \bibitem entries of a thebibliography environment in the TeX, converted to BibTeX with regular expressions: key, authors (first block), title (second \newblock, quotes or emphasis), venue, year, DOI, URL and arXiv identifier (turned into an arxiv.org/abs URL), entry type from the venue (In Proceedings → inproceedings, volume/journal → article, publisher → book);

  3. the .bbl file, only when the version has no .bib (natbib \bibitem lists and biblatex \entry records are both supported).

Deduplication. Within a paper, entries that share a DOI, a normalized title, or a key are one reference. The key used by the latest version is kept, every \cite{} of the other keys is renamed to it, and the fields are unioned (the latest non-empty value wins), so no information is lost:

versionkeytitleauthoryeardoi
v1vaswani2017✓✓✓
v2vit_transformer✓✓✓✓
v3vit_transformer✓✓
unifiedvit_transformer✓✓✓✓
Source
<Figure size 770x396 with 1 Axes>
Loading...

6. Deduplication across versions

After cleanup and citation renaming, an element whose kind and content match exactly in two versions is stored once, so a single element_id serves both versions. Each version keeps its own root (<paper>#root1, <paper>#root2, ...) and its own parent edges, so the same sentence can sit under different headings in different versions. Element IDs are the publication key followed by a kind prefix and a counter: h heading, s sentence, e equation, f figure, l list, i item. The root is its own parent (parent_id is required to be non-null).

Source
<Figure size 770x396 with 1 Axes>
Loading...

Explore one paper

The tree below is generated from the parse output. Click a heading, list or item to expand it. Elements shared by several versions show the versions they appear in.

Source
Loading...

7. Version coverage

Source
<Figure size 770x396 with 1 Axes>
Loading...

8. Performance

Measured on Google Colab, CPU-only runtime (2 vCPU Intel Xeon @ 2.20 GHz, 13.6 GB RAM), with one worker process per CPU. Wall time covers python -m introds parse end to end and is cross-checked with GNU time -v; RAM is sampled every 2 seconds over the main process and its workers.

Source
Loading...
Source
<Figure size 770x396 with 1 Axes>

9. Output data

Each paper’s result is kept in parsed/<paper>.json.gz: its distinct elements, the node-parent edges of every version and its unified BibTeX entries, so the final tables are built without parsing again. A version without TeX sources yields no elements and stays recorded as empty. The three tables below are exported as sharded Parquet for the final dataset, published with Milestone 3.

Source
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

10. Limitations

  • The parser is regular-expression based, not a TeX engine: user macros (\newcommand) are not expanded, and unusual document classes may hide structure in custom commands.

  • Sentence splitting is rule based; very long “sentences” usually come from text without final punctuation (lists of items, captions).

  • \bibitem conversion relies on the usual \newblock layout; free-form references may get an incomplete title or venue.

11. References

12. Requirements checklist

Requirement (Milestone 2 statement)Where
Every version of every paper parsed; versions without TeX recorded as empty1, 7, 9
Root file, transitive \input / \include, commented commands ignored, auxiliary files ignored2, Figure 1
Hierarchy: document root, automatic levels, sentences, block formulas, figures, tables as figures3, Figure 2
Lists and items; references section excluded; acknowledgements and appendices included3
Sentence splitting that respects math, commands, abbreviations, URLs and decimals3
Formatting cleanup4
Inline and block math normalized4
\bibitem converted to BibTeX5, Figure 3
Reference deduplication: one key, \cite renamed, fields unioned5
Full-text deduplication across versions, after cleanup6, Figure 4
Element IDs; elements, hierarchy and bibtex tables6, 9
Parsing success rate1
Version coverage of every publication7, Figure 5
Element and entry counts before and after deduplication3, 5
End-to-end wall time and average time per publication8
Maximum RAM and final output size, on Colab CPU-only8, Figure 6
Figures and tables generated during book compilationevery figure and table on this page