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

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
01_quickstart.ipynb Download the dataset → parse a project from pre-processed CSVs → explore transliterations, translations, and metadata → export
02_reference_data.ipynb Browse all projects in the dataset, query catalogues, explore bundled reference data (provenance, periods, sign list, POS tags)
03_configure_and_export.ipynb All RunConfig options — word-level and sign-level break filtering, POS masking — combining multiple projects and exporting datasets
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
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.2.tar.gz (139.5 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.2-py3-none-any.whl (144.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: oracc_parser-0.1.2.tar.gz
  • Upload date:
  • Size: 139.5 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.2.tar.gz
Algorithm Hash digest
SHA256 7d78ef97a8e8d55aa635188119fa67e1e39f69b55ee7e270d97c608aea7ea31f
MD5 7e8dc9591da847f84652a44751579381
BLAKE2b-256 8fbe3d021db639b2bb81b24ff8b80acbabd443b69a8d1aa7d4ad2e1ab09e0161

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oracc_parser-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 144.5 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 50b7c99da6275e6e58ed9790de278110c8a7113493d1fad152f969fe7738cc13
MD5 58cdd61ebd68864495b37905021664b3
BLAKE2b-256 d7e4af2fc33f124b7a380424307409fe9ae2a5a5cc74f7819e83e29a95eb3e6f

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