Skip to main content

Extract semantic sections (future work, limitations, conclusion, ...) from arXiv LaTeX sources.

Project description

arxiv-sectionizer

Extract semantic sections — Future Work, Limitations, Conclusion, Discussion, etc. — from arXiv LaTeX source archives. Zero runtime dependencies.

The arxiv package hands you metadata and a PDF URL. This library hands you the sections you actually want, pulled from LaTeX source with \input{} / \include{} / \subfile{} includes resolved.

Install

pip install arxiv-sectionizer

Quickstart

from arxiv_sectionizer import sectionize

# Accepts a tar.gz path, raw bytes, a .gz, or a .tex string.
for s in sectionize("2401.01234.tar.gz", kinds="future_work"):
    print(s.title)
    print(s.body[:300])

Want every section? Omit kinds:

sections = sectionize("paper.tar.gz")
for s in sections:
    print(s.kind or "-", s.level, s.title)

Lower-level API

from arxiv_sectionizer import read_archive, flatten, extract_sections, find_sections

files = read_archive("paper.tar.gz")          # dict[str, str] of every .tex member
tex = flatten(files)                          # resolve \input{}/\include{}/\subfile{}
sections = extract_sections(tex)              # all sections, with .kind classification
future = find_sections(tex, "future_work")    # only matching categories

Each Section is:

Section(
    title: str,
    body: str,
    level: int,          # 0=chapter, 1=section, 2=subsection, ...
    kind: str | None,    # "future_work" | "limitations" | "conclusion" | ...
    start: int,          # byte offsets into the flattened source
    end: int,
)

Custom categories

The default category map covers the usual targets. Override it with your own keyword map:

from arxiv_sectionizer import Categories, extract_sections

cats = Categories(mapping={
    "open_problems": ("open problem", "unsolved"),
    "ablation":      ("ablation",),
})
sections = extract_sections(tex, categories=cats, only_classified=True)

Default categories: future_work, limitations, conclusion, discussion, related_work, introduction, abstract, methods, results.

CLI

arxiv-sectionize paper.tar.gz --kind future_work,limitations
arxiv-sectionize paper.tar.gz --titles-only
arxiv-sectionize paper.tar.gz --json > sections.json

Why

Every paper-mining pipeline re-implements "give me this section from this paper" over LaTeX, and every implementation re-discovers the same edge cases:

  • nested \subsection / \paragraph
  • starred forms (\section*{...})
  • titles with inline LaTeX commands (\section{Results on \textsc{LibriTTS}})
  • split-file papers using \input{conclusion}
  • comment-outed sections (% \section{Old})
  • PDF-only submissions with no .tex source

This library handles those once.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arxiv_sectionizer-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

arxiv_sectionizer-0.1.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file arxiv_sectionizer-0.1.0.tar.gz.

File metadata

  • Download URL: arxiv_sectionizer-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for arxiv_sectionizer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d691fa9b17a0f61e67600e742af9ea0c077f253cd3efc5d5be1f24328a72d139
MD5 2843e548098a9d5534c932cffd921227
BLAKE2b-256 9ec31794ed0bcd67521b3a1c24a4479d7b80d3109757b31e4ede7c90ef9087e4

See more details on using hashes here.

File details

Details for the file arxiv_sectionizer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for arxiv_sectionizer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ffa9d3a6f623c68e95d82998703e79275ae651e5920d559c9f725536a2b238ed
MD5 0253caf1a44e3abce4e7b6c6379e87f6
BLAKE2b-256 42115f654451fe681aac5c3b019e7c29e365c895231341939aca97a7bb2ce4fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page