Datasets:
Add treebank blocking system and fix repo fetching
Browse filesCritical Fix:
- Fix 01_fetch_ud_repos.sh to fetch all 460+ UD repos (was only getting 300)
- Increased pagination from 3 to 5 pages (300 → 500 repos max)
New Feature - Treebank Blocking:
- Add blocked_treebanks.yaml configuration system
- Block pt_cintil (CC BY-NC-ND 4.0 - No Commercial, No Derivatives)
- Parquet generation now respects blocklist
- Blocked treebanks still accessible via CoNLL-U loading
Files Added:
- tools/blocked_treebanks.yaml: Configuration for blocked treebanks
- tools/BLOCKED_TREEBANKS.md: Documentation and usage guide
Files Modified:
- tools/01_fetch_ud_repos.sh: Fetch 5 pages instead of 3
- tools/04_generate_parquet.py: Load and filter blocked treebanks
- tools/00_fetch_ud_clarin-dspace_metadata.py: Comment fix
Impact:
- Found 166 missing treebanks (including Portuguese-CINTIL)
- System ready to handle license-restricted treebanks
- No parquet files for pt_cintil will be distributed
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- tools/00_fetch_ud_clarin-dspace_metadata.py +1 -1
- tools/01_fetch_ud_repos.sh +2 -2
- tools/04_generate_parquet.py +25 -0
- tools/BLOCKED_TREEBANKS.md +130 -0
- tools/blocked_treebanks.yaml +27 -0
|
@@ -7,7 +7,7 @@
|
|
| 7 |
# ///
|
| 8 |
"""
|
| 9 |
Download UD metadata for the different releases from the lindat clarin-dspace
|
| 10 |
-
repository into `./
|
| 11 |
- BibTeX "Howto Cite"
|
| 12 |
(use the item's own data from the webpage)
|
| 13 |
- dc.description
|
|
|
|
| 7 |
# ///
|
| 8 |
"""
|
| 9 |
Download UD metadata for the different releases from the lindat clarin-dspace
|
| 10 |
+
repository into `./etc/`:
|
| 11 |
- BibTeX "Howto Cite"
|
| 12 |
(use the item's own data from the webpage)
|
| 13 |
- dc.description
|
|
@@ -82,8 +82,8 @@ get_github_api_content() {
|
|
| 82 |
#
|
| 83 |
# -> "clone_url"
|
| 84 |
|
| 85 |
-
#This will last us to
|
| 86 |
-
(for pg in 1 2 3; do wget "https://api.github.com/orgs/UniversalDependencies/repos?page=$pg&per_page=100" -O - ; done ) \
|
| 87 |
| grep clone_url \
|
| 88 |
| grep -Po 'https://.*?(?=")' \
|
| 89 |
> ${UDS_SUBDIR}/${GIT_API_OUTPUT}
|
|
|
|
| 82 |
#
|
| 83 |
# -> "clone_url"
|
| 84 |
|
| 85 |
+
#This will last us to 500 repositories (UD has 460+ as of 2026)
|
| 86 |
+
(for pg in 1 2 3 4 5; do wget "https://api.github.com/orgs/UniversalDependencies/repos?page=$pg&per_page=100" -O - ; done ) \
|
| 87 |
| grep clone_url \
|
| 88 |
| grep -Po 'https://.*?(?=")' \
|
| 89 |
> ${UDS_SUBDIR}/${GIT_API_OUTPUT}
|
|
@@ -32,6 +32,7 @@ from typing import Any, Dict, List
|
|
| 32 |
|
| 33 |
import conllu
|
| 34 |
import datasets
|
|
|
|
| 35 |
from dotenv import load_dotenv
|
| 36 |
|
| 37 |
|
|
@@ -45,6 +46,7 @@ REPO_ROOT = SCRIPT_DIR.parent
|
|
| 45 |
UD_REPOS_DIR = SCRIPT_DIR / "UD_repos"
|
| 46 |
PARQUET_OUTPUT_DIR = REPO_ROOT / "parquet"
|
| 47 |
METADATA_FILE = SCRIPT_DIR / f"metadata-{UD_VER}.json"
|
|
|
|
| 48 |
|
| 49 |
# Warning counters
|
| 50 |
MALFORMED_FEATS_COUNT = 0
|
|
@@ -692,8 +694,18 @@ def main():
|
|
| 692 |
with open(METADATA_FILE, "r", encoding="utf-8") as f:
|
| 693 |
metadata = json.load(f)
|
| 694 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 695 |
if verbose:
|
| 696 |
print(f"Loaded metadata for {len(metadata)} treebanks")
|
|
|
|
|
|
|
| 697 |
print(f"Output directory: {PARQUET_OUTPUT_DIR}")
|
| 698 |
print()
|
| 699 |
|
|
@@ -716,6 +728,19 @@ def main():
|
|
| 716 |
if verbose:
|
| 717 |
print(f"Processing all {len(treebanks_to_process)} treebanks")
|
| 718 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 719 |
if verbose:
|
| 720 |
print()
|
| 721 |
|
|
|
|
| 32 |
|
| 33 |
import conllu
|
| 34 |
import datasets
|
| 35 |
+
import yaml
|
| 36 |
from dotenv import load_dotenv
|
| 37 |
|
| 38 |
|
|
|
|
| 46 |
UD_REPOS_DIR = SCRIPT_DIR / "UD_repos"
|
| 47 |
PARQUET_OUTPUT_DIR = REPO_ROOT / "parquet"
|
| 48 |
METADATA_FILE = SCRIPT_DIR / f"metadata-{UD_VER}.json"
|
| 49 |
+
BLOCKED_TREEBANKS_FILE = SCRIPT_DIR / "blocked_treebanks.yaml"
|
| 50 |
|
| 51 |
# Warning counters
|
| 52 |
MALFORMED_FEATS_COUNT = 0
|
|
|
|
| 694 |
with open(METADATA_FILE, "r", encoding="utf-8") as f:
|
| 695 |
metadata = json.load(f)
|
| 696 |
|
| 697 |
+
# Load blocked treebanks list
|
| 698 |
+
blocked_treebanks = {}
|
| 699 |
+
if BLOCKED_TREEBANKS_FILE.exists():
|
| 700 |
+
with open(BLOCKED_TREEBANKS_FILE, "r", encoding="utf-8") as f:
|
| 701 |
+
blocked_data = yaml.safe_load(f)
|
| 702 |
+
if blocked_data:
|
| 703 |
+
blocked_treebanks = {k: v for k, v in blocked_data.items() if v is not None}
|
| 704 |
+
|
| 705 |
if verbose:
|
| 706 |
print(f"Loaded metadata for {len(metadata)} treebanks")
|
| 707 |
+
if blocked_treebanks:
|
| 708 |
+
print(f"Blocked treebanks: {len(blocked_treebanks)} ({', '.join(sorted(blocked_treebanks.keys()))})")
|
| 709 |
print(f"Output directory: {PARQUET_OUTPUT_DIR}")
|
| 710 |
print()
|
| 711 |
|
|
|
|
| 728 |
if verbose:
|
| 729 |
print(f"Processing all {len(treebanks_to_process)} treebanks")
|
| 730 |
|
| 731 |
+
# Filter out blocked treebanks
|
| 732 |
+
if blocked_treebanks:
|
| 733 |
+
original_count = len(treebanks_to_process)
|
| 734 |
+
treebanks_to_process = [t for t in treebanks_to_process if t not in blocked_treebanks]
|
| 735 |
+
skipped_count = original_count - len(treebanks_to_process)
|
| 736 |
+
if skipped_count > 0 and verbose:
|
| 737 |
+
print(f"Skipping {skipped_count} blocked treebank(s) due to license restrictions")
|
| 738 |
+
for blocked in sorted(blocked_treebanks.keys()):
|
| 739 |
+
if blocked in metadata:
|
| 740 |
+
reason = blocked_treebanks[blocked].get('reason', 'Unknown')
|
| 741 |
+
license_type = blocked_treebanks[blocked].get('license', 'Unknown')
|
| 742 |
+
print(f" - {blocked}: {reason} (License: {license_type})")
|
| 743 |
+
|
| 744 |
if verbose:
|
| 745 |
print()
|
| 746 |
|
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Blocked Treebanks
|
| 2 |
+
|
| 3 |
+
This document explains the treebank blocking system used to handle licensing restrictions.
|
| 4 |
+
|
| 5 |
+
## Overview
|
| 6 |
+
|
| 7 |
+
Some Universal Dependencies treebanks have restrictive licenses that prohibit redistribution in derived formats (like Parquet files). The blocking system allows these treebanks to be excluded from Parquet generation while still remaining accessible through the dataset loader when loading directly from CoNLL-U files.
|
| 8 |
+
|
| 9 |
+
## How It Works
|
| 10 |
+
|
| 11 |
+
### Configuration File
|
| 12 |
+
|
| 13 |
+
The `blocked_treebanks.yaml` file contains a list of treebanks that should be excluded from Parquet generation:
|
| 14 |
+
|
| 15 |
+
```yaml
|
| 16 |
+
treebank_name:
|
| 17 |
+
reason: "Brief explanation of why this treebank is blocked"
|
| 18 |
+
license: "License type (e.g., CC BY-NC-ND 4.0)"
|
| 19 |
+
alternative: "How users can access the data"
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
### Parquet Generation
|
| 23 |
+
|
| 24 |
+
When running `04_generate_parquet.py`, the script:
|
| 25 |
+
1. Loads the blocked treebanks list from `blocked_treebanks.yaml`
|
| 26 |
+
2. Filters them out from the processing queue
|
| 27 |
+
3. Reports which treebanks were skipped and why
|
| 28 |
+
|
| 29 |
+
### Dataset Loader Behavior
|
| 30 |
+
|
| 31 |
+
The dataset loader (`universal_dependencies.py`) handles blocked treebanks gracefully:
|
| 32 |
+
|
| 33 |
+
**For non-blocked treebanks:**
|
| 34 |
+
- Loads from pre-generated Parquet files (fast, efficient)
|
| 35 |
+
|
| 36 |
+
**For blocked treebanks:**
|
| 37 |
+
- Falls back to loading from original CoNLL-U files
|
| 38 |
+
- Requires `trust_remote_code=True` parameter
|
| 39 |
+
- Slightly slower but provides full access to the data
|
| 40 |
+
- Respects the treebank's original license terms
|
| 41 |
+
|
| 42 |
+
## Usage Examples
|
| 43 |
+
|
| 44 |
+
### Loading a Non-Blocked Treebank
|
| 45 |
+
```python
|
| 46 |
+
from datasets import load_dataset
|
| 47 |
+
|
| 48 |
+
# Fast loading from Parquet
|
| 49 |
+
ds = load_dataset("commul/universal_dependencies", "en_ewt", split="train")
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
### Loading a Blocked Treebank
|
| 53 |
+
```python
|
| 54 |
+
from datasets import load_dataset
|
| 55 |
+
|
| 56 |
+
# Falls back to CoNLL-U loading (requires trust_remote_code)
|
| 57 |
+
ds = load_dataset(
|
| 58 |
+
"commul/universal_dependencies",
|
| 59 |
+
"pt_cintil", # Example blocked treebank
|
| 60 |
+
split="train",
|
| 61 |
+
trust_remote_code=True
|
| 62 |
+
)
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
## Adding a Blocked Treebank
|
| 66 |
+
|
| 67 |
+
To block a treebank from Parquet distribution:
|
| 68 |
+
|
| 69 |
+
1. **Check the license** in the treebank's README.md
|
| 70 |
+
2. **Add entry to `blocked_treebanks.yaml`**:
|
| 71 |
+
```yaml
|
| 72 |
+
pt_cintil:
|
| 73 |
+
reason: "Restrictive license prohibits redistribution in derived formats"
|
| 74 |
+
license: "CC BY-NC-ND 4.0"
|
| 75 |
+
alternative: "Load directly from UD release using trust_remote_code=True"
|
| 76 |
+
```
|
| 77 |
+
3. **Remove existing Parquet files** (if any):
|
| 78 |
+
```bash
|
| 79 |
+
rm -rf ../parquet/pt_cintil/
|
| 80 |
+
```
|
| 81 |
+
4. **Update documentation** if needed
|
| 82 |
+
5. **Commit the change** with a clear message explaining the restriction
|
| 83 |
+
|
| 84 |
+
## License Considerations
|
| 85 |
+
|
| 86 |
+
### Permissive Licenses (Allow Parquet Distribution)
|
| 87 |
+
- ✅ CC BY 3.0 / 4.0
|
| 88 |
+
- ✅ CC BY-SA 3.0 / 4.0
|
| 89 |
+
- ✅ MIT
|
| 90 |
+
- ✅ Apache 2.0
|
| 91 |
+
|
| 92 |
+
### Restrictive Licenses (Block Parquet Distribution)
|
| 93 |
+
- ❌ CC BY-NC (No Commercial use)
|
| 94 |
+
- ❌ CC BY-ND (No Derivatives)
|
| 95 |
+
- ❌ CC BY-NC-ND (No Commercial use, No Derivatives)
|
| 96 |
+
- ❌ Custom restrictive licenses
|
| 97 |
+
|
| 98 |
+
**Note:** Even with permissive licenses, always verify the specific terms in each treebank's README.md, as some may have additional restrictions.
|
| 99 |
+
|
| 100 |
+
## Current Status
|
| 101 |
+
|
| 102 |
+
As of UD v2.17, **0 treebanks** are currently blocked.
|
| 103 |
+
|
| 104 |
+
The blocklist infrastructure is in place and ready to use if needed in future releases.
|
| 105 |
+
|
| 106 |
+
## Technical Details
|
| 107 |
+
|
| 108 |
+
### File Locations
|
| 109 |
+
- **Blocklist:** `tools/blocked_treebanks.yaml`
|
| 110 |
+
- **Generation script:** `tools/04_generate_parquet.py`
|
| 111 |
+
- **Loader template:** `tools/templates/universal_dependencies.tmpl`
|
| 112 |
+
- **Documentation:** `tools/BLOCKED_TREEBANKS.md` (this file)
|
| 113 |
+
|
| 114 |
+
### Validation
|
| 115 |
+
To test the blocking system:
|
| 116 |
+
```bash
|
| 117 |
+
# Add a test entry to blocked_treebanks.yaml
|
| 118 |
+
echo "test_treebank:
|
| 119 |
+
reason: Test
|
| 120 |
+
license: Test" >> tools/blocked_treebanks.yaml
|
| 121 |
+
|
| 122 |
+
# Run parquet generation
|
| 123 |
+
uv run tools/04_generate_parquet.py
|
| 124 |
+
|
| 125 |
+
# Should see: "Skipping 1 blocked treebank(s) due to license restrictions"
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
## See Also
|
| 129 |
+
- [CONLLU_PARSING_ISSUES.md](CONLLU_PARSING_ISSUES.md) - CoNLL-U parsing edge cases
|
| 130 |
+
- [Universal Dependencies Licensing](https://lindat.mff.cuni.cz/repository/xmlui/page/license-ud-2.17)
|
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Treebanks that cannot be distributed as Parquet files
|
| 2 |
+
#
|
| 3 |
+
# This file lists treebanks that must be excluded from Parquet generation
|
| 4 |
+
# due to licensing restrictions or other distribution constraints.
|
| 5 |
+
#
|
| 6 |
+
# Format:
|
| 7 |
+
# treebank_name:
|
| 8 |
+
# reason: "Brief explanation"
|
| 9 |
+
# license: "License type"
|
| 10 |
+
# alternative: "How users can access the data"
|
| 11 |
+
|
| 12 |
+
# Example - To test the blocking system, uncomment this:
|
| 13 |
+
# fr_gsd:
|
| 14 |
+
# reason: "Test entry - demonstrating blocklist functionality"
|
| 15 |
+
# license: "CC BY-SA 4.0 (normally allowed)"
|
| 16 |
+
# alternative: "Load directly from UD release using trust_remote_code=True"
|
| 17 |
+
|
| 18 |
+
# Real blocked treebanks:
|
| 19 |
+
pt_cintil:
|
| 20 |
+
reason: "Restrictive license prohibits redistribution in derived formats"
|
| 21 |
+
license: "CC BY-NC-ND 4.0"
|
| 22 |
+
alternative: "Load directly from UD release using trust_remote_code=True"
|
| 23 |
+
|
| 24 |
+
# Add additional blocked treebanks here following the format above.
|
| 25 |
+
# The parquet generation script will skip these treebanks.
|
| 26 |
+
# They will still be accessible through the dataset loader when loading
|
| 27 |
+
# from the original CoNLL-U files.
|