Skip to main content

Download and parse ORACC cuneiform text projects into ML-ready formats

Project description

oracc-parser

A Python tool to download and parse ORACC cuneiform text projects into machine-learning-ready formats (JSONL, CSV, pandas DataFrames).

Features

  • Download — Fetch project ZIPs directly from ORACC or Zenodo
  • Parse — Convert raw ORACC JSON into structured data
  • Export — Save datasets as JSONL, CSV, or pandas DataFrames
  • Configure — Control handling of broken signs and POS masking using RunConfig

Installation

pip install oracc-parser

Or for development:

git clone https://github.com/shaharspencer/oracc-parser.git
cd oracc-parser
pip install -e ".[dev]"

Getting Started — Notebooks

The easiest way to explore oracc-parser is through the interactive notebooks. Start with notebook 01 — it downloads all the data you need from Zenodo automatically.

Notebook What you'll learn Open in Colab
01_quickstart.ipynb Download the dataset → parse a project → explore transliterations, translations, and metadata → export Open In Colab
02_reference_data.ipynb Browse all projects in the dataset, query catalogues, explore bundled reference data (provenance, periods, sign list, POS tags) Open In Colab
03_configure_and_export.ipynb All RunConfig options — word-level and sign-level break filtering, POS masking — combining multiple projects and exporting datasets Open In Colab
04_oracc_json_processing.ipynb Advanced: understand the raw ORACC JSON structure, the JSON → TabletRecord → CSV pipeline, and how to download and parse projects not in the dataset Open In Colab
05_translations.ipynb Where translations come from, how to download the translation cache from Zenodo, and how to enable translations in the parsing pipeline Open In Colab
pip install oracc-parser[notebooks]
jupyter notebook notebooks/

Quick Example

from oracc_parser import parse_project, RunConfig, get_full_flat_table

# Parse 5 tablets from SAA 01 (Neo-Assyrian royal letters)
records = parse_project("saao/saa01", config=RunConfig(limit=5))

# Get a flat DataFrame — no nesting, ready for analysis
df = get_full_flat_table(records)
df.to_json("dataset.jsonl", orient="records", lines=True)

Configuration

You can customize the parsing process using RunConfig:

from oracc_parser import parse_project, RunConfig

records = parse_project("saao/saa01", config=RunConfig(
    limit=10,
    max_break_fraction=0.5,   # word-level: drop words that are >50% broken
    drop_missing=True,        # sign-level: drop [x] signs from Unicode output
    drop_damaged=False,       # sign-level: keep ⸢x⸣ signs in Unicode output
    mask_pos=["PN", "DN"],    # replace personal/divine names with tag
))

Two independent levels of break filtering

RunConfig provides two distinct ways to handle damaged or missing text, operating at different granularities and affecting different outputs:

Parameter Level Affects How it works
max_break_fraction Word Transliteration, normalization, lemmatization Each word has a break_perc (fraction of its signs that are broken). Words exceeding this threshold are replaced with X. Default 1.0 keeps all words.
drop_missing Sign Unicode cuneiform only Drops individual signs marked [x] (completely lost).
drop_damaged Sign Unicode cuneiform only Drops individual signs marked ⸢x⸣ (partially legible).

Note: Because word-level and sign-level filtering use different thresholds and different granularities, the text outputs and the Unicode cuneiform output are not necessarily aligned. A word kept in the transliteration (because its average damage is below max_break_fraction) may still have individual signs dropped from the Unicode output if drop_missing / drop_damaged are enabled.

Other options

Parameter Default Description
limit None Only parse the first N texts (useful for testing)
keep_word_segmentation True Preserve word boundaries in Unicode cuneiform output
mask_pos [] Replace words of certain POS tags with the tag name
languages ["Akkadian"] Which languages to include when downloading projects
use_cache True Use cached results if available

All reference data is bundled with the package, so you don't need to configure external paths unless you are customizing oracc_parser.settings.

CLI

oracc-parser download --project saao/saa01
oracc-parser parse --project saao/saa01 --limit 5 --format jsonl --output saa01.jsonl

Heavy Data (Zenodo)

Large data files (ORACC ZIPs, cached translations, Pleiades data) are on Zenodo:

DOI

python scripts/download_zenodo_data.py

Running Tests

pytest tests/ -v     # 98 tests

Known Limitations

  • Chronology: Period-to-year normalization is optimized for the 1st Millennium BCE.
  • Language: Parsing is primarily validated on Akkadian projects.

License

MIT — see LICENSE.

Credits

Based on code by Niek Veldhuis (Compass) and adapted for the BEn Project.

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

oracc_parser-0.1.3.tar.gz (136.1 kB view details)

Uploaded Source

Built Distribution

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

oracc_parser-0.1.3-py3-none-any.whl (141.8 kB view details)

Uploaded Python 3

File details

Details for the file oracc_parser-0.1.3.tar.gz.

File metadata

  • Download URL: oracc_parser-0.1.3.tar.gz
  • Upload date:
  • Size: 136.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for oracc_parser-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ce006cc48e0787fe5e6591eee85b4e233cbceca0e50f4970745f36a140dc8ca3
MD5 fb3ff7785fd80ae9e0d8128887b97c78
BLAKE2b-256 08f1bb12d1aff9d998f12804e6051733a17b68045c032d9768f18245ba18f826

See more details on using hashes here.

File details

Details for the file oracc_parser-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: oracc_parser-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 141.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for oracc_parser-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 11bcdfda9ca06eed890c72cae52e7694fefabf725db69700b9e3a481c8b1a289
MD5 b05eee18b0acf361edb03a3b6b9b2303
BLAKE2b-256 a744c99c20649f9cb62b45d8526adb8b3f143a5ac0b0808eebe00dfd597c99d4

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