# tools/ Directory Quick reference for the Universal Dependencies dataset generation pipeline. ## Quick Start: Add New UD Version ```bash # Set version export NEW_VER=2.18 cd tools echo "UD_VER=${NEW_VER}" > .env # Fetch metadata ./00_fetch_ud_clarin-dspace_metadata.py -o ./00_fetch_ud_codes_and_flags.sh -o ./01_fetch_ud_repos.sh # Initialize repositories cd UD_repos git init bash ../.UD_submodules_add.commands git submodule foreach "git fetch --tags && git checkout r${NEW_VER} && touch .tag-r${NEW_VER}" cd .. # Generate files ./02_generate_metadata.py -o ./03_generate_README.py -o uv run ./04_generate_parquet.py uv run ./05_validate_parquet.py --local --test # Sync to root cp README-${NEW_VER} ../README.md cp metadata-${NEW_VER}.json ../metadata.json git add ../parquet ../README.md ../metadata.json ``` **For detailed instructions, see:** [ADDING_NEW_UD_VERSION.md](../ADDING_NEW_UD_VERSION.md) ## Pipeline Scripts ### 00 - Fetch Metadata **00_fetch_ud_clarin-dspace_metadata.py** - Downloads citation and description from LINDAT/CLARIN repository - Creates: `etc/citation-{VER}`, `etc/description-{VER}` - Update `url_postfixes` dict for new versions **00_fetch_ud_codes_and_flags.sh** - Downloads language codes and flags from UD docs-automation - Creates: `etc/codes_and_flags-{VER}.yaml`, `etc/codes_and_flags-latest.yaml` - Update `VER_MAPPING` for new versions ### 01 - Fetch Repositories **01_fetch_ud_repos.sh** - Discovers all UD repositories on GitHub - Creates: `.UD_submodules_add.commands` - Run commands in `UD_repos/` directory to fetch all treebanks ### 02 - Generate Metadata **02_generate_metadata.py** - Extracts metadata from local UD directories - Collects: summaries, licenses, splits, statistics, blocked status - Creates: `metadata-{VER}.json` - Reads: `blocked_treebanks.yaml` for license restrictions ### 03 - Generate README **03_generate_README.py** - Renders Jinja2 template with metadata - Creates: `README-{VER}` (HuggingFace dataset card) - Uses: `templates/README.tmpl`, `metadata-{VER}.json`, `etc/citation-{VER}`, `etc/description-{VER}` ### 04 - Generate Parquet **04_generate_parquet.py** - Wrapper script calling `ud-hf-parquet-tools` library - Converts CoNLL-U files to Parquet format - Creates: `../parquet/{treebank}/{split}.parquet` - Options: `--test`, `--overwrite`, `--blocked-treebanks` ### 05 - Validate Parquet **05_validate_parquet.py** - Wrapper script calling `ud-hf-parquet-tools` library - Validates Parquet files against CoNLL-U source - Options: `--local`, `--test`, `--mode text` ## Directory Structure ``` tools/ ├── 00_fetch_ud_clarin-dspace_metadata.py # Fetch citation/description ├── 00_fetch_ud_codes_and_flags.sh # Fetch language metadata ├── 01_fetch_ud_repos.sh # Discover UD repos ├── 02_generate_metadata.py # Extract treebank metadata ├── 03_generate_README.py # Generate dataset card ├── 04_generate_parquet.py # Generate Parquet files ├── 05_validate_parquet.py # Validate Parquet files ├── blocked_treebanks.yaml # License-restricted treebanks ├── etc/ │ ├── citation-{VER} # Generated citations │ ├── description-{VER} # Generated descriptions │ └── codes_and_flags-{VER}.yaml # Language metadata ├── templates/ │ └── README.tmpl # Jinja2 template for dataset card ├── metadata-{VER}.json # Generated metadata (output) ├── README-{VER} # Generated dataset card (output) └── UD_repos/ # Git submodules (created by 01) ├── UD_{Language}-{Treebank}/ # Individual treebanks └── .UD_submodules_add.commands # Generated submodule commands ``` ## Configuration **Environment Variables (.env)** ```bash UD_VER=2.17 # Current UD version ``` **Blocked Treebanks (blocked_treebanks.yaml)** ```yaml pt_cintil: reason: "Restrictive license prohibits redistribution in derived formats" license: "CC BY-NC-SA 4.0" url: "https://github.com/UniversalDependencies/UD_Portuguese-CINTIL" ``` ## Dependencies - Python 3.12+ - `uv` (for running scripts with dependencies) - `ud-hf-parquet-tools` (for parquet generation/validation) - Git with submodules support Install dependencies: ```bash pip install ud-hf-parquet-tools pyyaml python-dotenv jinja2 ``` ## Common Operations **Test on subset:** ```bash uv run ./04_generate_parquet.py --test # Tests 3 treebanks uv run ./05_validate_parquet.py --test # Validates 3 treebanks ``` **Force regeneration:** ```bash ./02_generate_metadata.py -o # Override existing ./03_generate_README.py -o uv run ./04_generate_parquet.py --overwrite ``` **Skip blocked treebanks:** ```bash uv run ./04_generate_parquet.py --blocked-treebanks blocked_treebanks.yaml ``` ## Troubleshooting **Script not found:** - Scripts use `#!/usr/bin/env -S uv run --script` shebang - Make executable: `chmod +x *.py *.sh` - Or run with: `uv run --script ./script.py` **Missing dependencies:** ```bash pip install ud-hf-parquet-tools ``` **Submodule checkout fails:** ```bash cd UD_repos git submodule foreach 'git fetch --tags && (git checkout r2.17 || git checkout main)' ``` ## Documentation - **Comprehensive guide:** [ADDING_NEW_UD_VERSION.md](../ADDING_NEW_UD_VERSION.md) - **Blocked treebanks:** [BLOCKED_TREEBANKS.md](BLOCKED_TREEBANKS.md) - **Migration guide:** [MIGRATION.md](../MIGRATION.md) - **Parquet tools:** https://github.com/bot-zen/ud-hf-parquet-tools