Datasets:
Translation-resource audit of 325 FineWiki languages (finewiki_audit_20261114T182048Z)
Browse filesFiles changed (10)
- README.md+4-1
- manifest.json+26-21
- scripts/build_eval_corpus.py+604-17
- scripts/build_lexicon_corpus.pyAdded+713
- scripts/publish_corpus.py+132-2
- scripts/stage_audit_extras.py+22-4
- selected_languages.json+356-62
- selected_languages.md+26-28
- tests/test_eval_corpus.py+27-7
- tests/test_lexicon_corpus.pyAdded+205
172 unmodified lines1731741751761771788 unmodified lines1871881891901911921 unmodified line194195196197198199200172 unmodified linespython scripts/shortlist_pivots.pypython scripts/build_eval_corpus.pypython scripts/build_baseline_corpus.pypython scripts/stage_audit_extras.pypython scripts/publish_lang_audit.pypython scripts/publish_corpus.py8 unmodified lines| `scripts/shortlist_pivots.py` | Derives the shortlist from the row state and chooses each language's pivots. || `scripts/build_eval_corpus.py` | Gathers the human-written test sets for the shortlist into the evaluation dataset. || `scripts/build_baseline_corpus.py` | Downloads the existing OPUS and Tatoeba training data as the comparison baseline. || `scripts/corpus_subsets.py` | Shared subset writer used by both corpus builders (<source>-<language> configs). || `scripts/stage_audit_extras.py` | Adds this script bundle and selected_languages.json to the staged audit release. || `scripts/publish_lang_audit.py` | Validates the staged release, uploads it and waits for the Dataset Viewer. |1 unmodified line| `scripts/hf_publishing_auth.py` | Reads the write token from the macOS Keychain; no credential is ever written to disk. || `configs/community_benchmarks.json` | Curated community test sets (PARME, xSID, NaLiBaSID) with pinned revisions. || `tests/test_lang_audit.py` | Tests for the audit: code resolution, prefix collisions, thresholds, derived columns. || `tests/test_eval_corpus.py` | Tests for both corpus builders: parsing, pivots, de-duplication, contamination. |The tests run with `.venv-publish/bin/python -m unittest discover -s tests -q`.172 unmodified lines1731741751761771781798 unmodified lines1881891901911921931941 unmodified line196197198199200201202203172 unmodified linespython scripts/shortlist_pivots.pypython scripts/build_eval_corpus.pypython scripts/build_baseline_corpus.pypython scripts/build_lexicon_corpus.pypython scripts/stage_audit_extras.pypython scripts/publish_lang_audit.pypython scripts/publish_corpus.py8 unmodified lines| `scripts/shortlist_pivots.py` | Derives the shortlist from the row state and chooses each language's pivots. || `scripts/build_eval_corpus.py` | Gathers the human-written test sets for the shortlist into the evaluation dataset. || `scripts/build_baseline_corpus.py` | Downloads the existing OPUS and Tatoeba training data as the comparison baseline. || `scripts/build_lexicon_corpus.py` | Gathers bilingual dictionaries, wordlists and token glosses into the lexicon dataset. || `scripts/corpus_subsets.py` | Shared subset writer used by both corpus builders (<source>-<language> configs). || `scripts/stage_audit_extras.py` | Adds this script bundle and selected_languages.json to the staged audit release. || `scripts/publish_lang_audit.py` | Validates the staged release, uploads it and waits for the Dataset Viewer. |1 unmodified line| `scripts/hf_publishing_auth.py` | Reads the write token from the macOS Keychain; no credential is ever written to disk. || `configs/community_benchmarks.json` | Curated community test sets (PARME, xSID, NaLiBaSID) with pinned revisions. || `tests/test_lang_audit.py` | Tests for the audit: code resolution, prefix collisions, thresholds, derived columns. || `tests/test_eval_corpus.py` | Tests for the sentence corpora: parsing, pivots, de-duplication, contamination. || `tests/test_lexicon_corpus.py` | Tests for the lexicon corpus and the licence tiering both corpora share. |The tests run with `.venv-publish/bin/python -m unittest discover -s tests -q`.
903 unmodified lines904905906907908909910911912913914915916917918919920921922923924925926113 unmodified lines10401041104210431044104523 unmodified lines10691070107110721073107410751076107710781079108010811082108310841085108610871 unmodified line10891090109110921093109410958 unmodified lines11041105110611071108110911101111111211131114111511161117111811191120112111221123112420 unmodified lines1145114611471148114911501151903 unmodified lines"shortlist.json": "9eb370fd14a2913f17b480efac11289c9f44a8ee458a68428e96028c11525cc2","sources/finewiki_article_overlap.json": "2497aaf4a9a2f32ef716ccff8509f2e4c16808318429cf598bf29088ee070b82","sources/finewiki_article_coverage.json": "5c53008bf6e0d7b30b13890cea7ddca105b3f78cfb9699d9a945fbc0aab17573","selected_languages.json": "e98c808687283afdecf11aca901cb0f04c7ed3a95757bc48777ae9cd00d31951","selected_languages.md": "fa1d33736083726a6009d609b0bbd36276c9b7af761d29d389dfe19f7faccae4","scripts/lang_audit_sources.py": "e8074e36a09240d73c9891a7ee1f48b9483b45ee8c1816ca0d237abcd7e33ef3","scripts/lang_audit_overlap.py": "8c6ae3a88ef123a0d1a86c80d9b27394f5c7ffa6662398b291c96ad549e1b253","scripts/lang_audit_coverage.py": "4ae0d267ea3dde5e71ea6b02919d68081b77d5a327e8dbe74e9057f952447324","scripts/lang_audit_build.py": "0a61d4ff2fe59e3589054ed3548060df3880bcfc2736cd62b3d8089f8ffbe16f","scripts/shortlist_pivots.py": "2434fb92c24384bb34c84799ed53c02b059ccc1bcdadfe9fb0fed0fbbda0cae8","scripts/build_eval_corpus.py": "117644d3a9d409d9d3b0fd47422a77e060c7be8a322c93e867f2d35bc9218253","scripts/build_baseline_corpus.py": "7e96e4560bda0f5ffe7010b264d42db1b59f54cdf1e16ba6ce44267389bd9be6","scripts/corpus_subsets.py": "79cb36857537df1c911422abcd504e5ac3b10d3d69636dd6b576e2c88eb96b7c","scripts/stage_audit_extras.py": "ba8ef78f01fc3d8aed40b075d1df9cf55257c13bd1eb98cc673c6d374dcafbd0","scripts/publish_lang_audit.py": "937ce20efcae739401bf3432b59b15bbfc1346fce0660a6261a402c98e1d9064","scripts/publish_corpus.py": "473b701af48bb76a4b0b1e067dc232f8d7bb0208def1a519340d558c4f98add4","scripts/hf_publishing_auth.py": "9f5d3fd2f78c9d47d2622bd0e05c944d1aca97115d3eb5bee7eff0bc20d04e95","configs/community_benchmarks.json": "54c99f1f8d91fc72d76dac819176ac380256449785518e1078b3b9fc63c11682","tests/test_lang_audit.py": "2d9e9a45f882a8c877f145dc94e02adc2925cfc34bb4860f6db501044e4ca724","tests/test_eval_corpus.py": "8cd8f5fb199b5adb96668e63ee8827f100c6a712074ee7102d6c329c28346b2e"},"columns": ["finewiki_config",113 unmodified lines"scripts/shortlist_pivots.py","scripts/build_eval_corpus.py","scripts/build_baseline_corpus.py","scripts/corpus_subsets.py","scripts/stage_audit_extras.py","scripts/publish_lang_audit.py",23 unmodified lines},"scripts/build_eval_corpus.py": {"role": "Gathers the human-written test sets for the shortlist into the evaluation dataset.","sha256": "117644d3a9d409d9d3b0fd47422a77e060c7be8a322c93e867f2d35bc9218253"},"scripts/build_baseline_corpus.py": {"role": "Downloads the existing OPUS and Tatoeba training data as the comparison baseline.","sha256": "7e96e4560bda0f5ffe7010b264d42db1b59f54cdf1e16ba6ce44267389bd9be6"},"scripts/corpus_subsets.py": {"role": "Shared subset writer used by both corpus builders (<source>-<language> configs).","sha256": "79cb36857537df1c911422abcd504e5ac3b10d3d69636dd6b576e2c88eb96b7c"},"scripts/stage_audit_extras.py": {"role": "Adds this script bundle and selected_languages.json to the staged audit release.","sha256": "ba8ef78f01fc3d8aed40b075d1df9cf55257c13bd1eb98cc673c6d374dcafbd0"},"scripts/publish_lang_audit.py": {"role": "Validates the staged release, uploads it and waits for the Dataset Viewer.",1 unmodified line},"scripts/publish_corpus.py": {"role": "The same for the evaluation and baseline datasets.","sha256": "473b701af48bb76a4b0b1e067dc232f8d7bb0208def1a519340d558c4f98add4"},"scripts/hf_publishing_auth.py": {"role": "Reads the write token from the macOS Keychain; no credential is ever written to disk.",8 unmodified lines"sha256": "2d9e9a45f882a8c877f145dc94e02adc2925cfc34bb4860f6db501044e4ca724"},"tests/test_eval_corpus.py": {"role": "Tests for both corpus builders: parsing, pivots, de-duplication, contamination.","sha256": "8cd8f5fb199b5adb96668e63ee8827f100c6a712074ee7102d6c329c28346b2e"}}},"selected_languages": {"count": 22,"with_evaluation_data": 17,"without_any_test_data": ["azb","bug","dag","skr","wuu"],"configs": ["als","lld",20 unmodified lines],"evaluation_dataset": "sigiranic/underserved-translation-eval","baseline_dataset": "sigiranic/underserved-translation-baseline","evaluation_release": "eval_20261114T202652Z","baseline_release": "baseline_20261114T221020Z"}}903 unmodified lines904905906907908909910911912913914915916917918919920921922923924925926927928113 unmodified lines104210431044104510461047104823 unmodified lines107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941 unmodified line10961097109810991100110111028 unmodified lines111111121113111411151116111711181119112011211122112311241125112611271128112920 unmodified lines1150115111521153115411551156903 unmodified lines"shortlist.json": "9eb370fd14a2913f17b480efac11289c9f44a8ee458a68428e96028c11525cc2","sources/finewiki_article_overlap.json": "2497aaf4a9a2f32ef716ccff8509f2e4c16808318429cf598bf29088ee070b82","sources/finewiki_article_coverage.json": "5c53008bf6e0d7b30b13890cea7ddca105b3f78cfb9699d9a945fbc0aab17573","selected_languages.json": "8fb8b11e0002749c3084690eb0a262accaa5afecdaa5eec4b17142b508061328","selected_languages.md": "776167cb7846236f66ae7b226dc9f6b88ec332995594a0d52caa304513b0d97b","scripts/lang_audit_sources.py": "e8074e36a09240d73c9891a7ee1f48b9483b45ee8c1816ca0d237abcd7e33ef3","scripts/lang_audit_overlap.py": "8c6ae3a88ef123a0d1a86c80d9b27394f5c7ffa6662398b291c96ad549e1b253","scripts/lang_audit_coverage.py": "4ae0d267ea3dde5e71ea6b02919d68081b77d5a327e8dbe74e9057f952447324","scripts/lang_audit_build.py": "0a61d4ff2fe59e3589054ed3548060df3880bcfc2736cd62b3d8089f8ffbe16f","scripts/shortlist_pivots.py": "2434fb92c24384bb34c84799ed53c02b059ccc1bcdadfe9fb0fed0fbbda0cae8","scripts/build_eval_corpus.py": "b350af213274c84e9b9d67c05e43d9339a5ffb9438e70038f40982145ae5e4cc","scripts/build_baseline_corpus.py": "7e96e4560bda0f5ffe7010b264d42db1b59f54cdf1e16ba6ce44267389bd9be6","scripts/corpus_subsets.py": "79cb36857537df1c911422abcd504e5ac3b10d3d69636dd6b576e2c88eb96b7c","scripts/stage_audit_extras.py": "a2e48f3c1ee371085835827b624ae7c9653880143d18ec1d154dc958a7993fbb","scripts/publish_lang_audit.py": "937ce20efcae739401bf3432b59b15bbfc1346fce0660a6261a402c98e1d9064","scripts/publish_corpus.py": "991a4b368867de7de825ead7be8d95b225c6fb0c4731af04f3b94d82aaa6dac2","scripts/hf_publishing_auth.py": "9f5d3fd2f78c9d47d2622bd0e05c944d1aca97115d3eb5bee7eff0bc20d04e95","configs/community_benchmarks.json": "54c99f1f8d91fc72d76dac819176ac380256449785518e1078b3b9fc63c11682","tests/test_lang_audit.py": "2d9e9a45f882a8c877f145dc94e02adc2925cfc34bb4860f6db501044e4ca724","tests/test_eval_corpus.py": "40314dea957b2ca752ae89f3fd6ea0e172438d00365f190bd81f66995dd1fc16","scripts/build_lexicon_corpus.py": "4365141aab4f1633e6401b453910d7600949db8d033da40d309b3ea52ee861a5","tests/test_lexicon_corpus.py": "c2b4ffdcbc913d314c334db50c9d1b255918f70ac75ec5df143253901dab0a92"},"columns": ["finewiki_config",113 unmodified lines"scripts/shortlist_pivots.py","scripts/build_eval_corpus.py","scripts/build_baseline_corpus.py","scripts/build_lexicon_corpus.py","scripts/corpus_subsets.py","scripts/stage_audit_extras.py","scripts/publish_lang_audit.py",23 unmodified lines},"scripts/build_eval_corpus.py": {"role": "Gathers the human-written test sets for the shortlist into the evaluation dataset.","sha256": "b350af213274c84e9b9d67c05e43d9339a5ffb9438e70038f40982145ae5e4cc"},"scripts/build_baseline_corpus.py": {"role": "Downloads the existing OPUS and Tatoeba training data as the comparison baseline.","sha256": "7e96e4560bda0f5ffe7010b264d42db1b59f54cdf1e16ba6ce44267389bd9be6"},"scripts/build_lexicon_corpus.py": {"role": "Gathers bilingual dictionaries, wordlists and token glosses into the lexicon dataset.","sha256": "4365141aab4f1633e6401b453910d7600949db8d033da40d309b3ea52ee861a5"},"scripts/corpus_subsets.py": {"role": "Shared subset writer used by both corpus builders (<source>-<language> configs).","sha256": "79cb36857537df1c911422abcd504e5ac3b10d3d69636dd6b576e2c88eb96b7c"},"scripts/stage_audit_extras.py": {"role": "Adds this script bundle and selected_languages.json to the staged audit release.","sha256": "a2e48f3c1ee371085835827b624ae7c9653880143d18ec1d154dc958a7993fbb"},"scripts/publish_lang_audit.py": {"role": "Validates the staged release, uploads it and waits for the Dataset Viewer.",1 unmodified line},"scripts/publish_corpus.py": {"role": "The same for the evaluation and baseline datasets.","sha256": "991a4b368867de7de825ead7be8d95b225c6fb0c4731af04f3b94d82aaa6dac2"},"scripts/hf_publishing_auth.py": {"role": "Reads the write token from the macOS Keychain; no credential is ever written to disk.",8 unmodified lines"sha256": "2d9e9a45f882a8c877f145dc94e02adc2925cfc34bb4860f6db501044e4ca724"},"tests/test_eval_corpus.py": {"role": "Tests for the sentence corpora: parsing, pivots, de-duplication, contamination.","sha256": "40314dea957b2ca752ae89f3fd6ea0e172438d00365f190bd81f66995dd1fc16"},"tests/test_lexicon_corpus.py": {"role": "Tests for the lexicon corpus and the licence tiering both corpora share.","sha256": "c2b4ffdcbc913d314c334db50c9d1b255918f70ac75ec5df143253901dab0a92"}}},"selected_languages": {"count": 22,"with_evaluation_data": 22,"without_any_test_data": [],"configs": ["als","lld",20 unmodified lines],"evaluation_dataset": "sigiranic/underserved-translation-eval","baseline_dataset": "sigiranic/underserved-translation-baseline","evaluation_release": "eval_20261114T230126Z","baseline_release": "baseline_20261114T230143Z"}}
60 unmodified lines61626364656641 unmodified lines108109110111112113114115116142 unmodified lines259260261262263264265266267206 unmodified lines4744754764774784794804814824834844854864874884894904914924934944954964974984995005015025032 unmodified lines50650750850951051151251351451551651726 unmodified lines5445455465475485495504 unmodified lines555556557558559560112 unmodified lines67367467567667767867968068168268360 unmodified linesNALIBASID_REVISION = "8d66b9021c06df1ab459636a925e119b2cff20fe"NTREX_REVISION = "468c6b69c7f6a75d31d4743d9daba2af566cc18d"PARME_REVISION = "6df9269acc75377ed6be3bf2f7966c8e238a62bd"SOURCE_META = {"tatoeba_challenge": {41 unmodified lines"note": "Text withheld. Access requires agreeing not to re-host FLORES+ where web ""crawlers could reach it, which a public dataset repository would do. Fetch ""it from the upstream repository after accepting its terms.",},}# xSID ships automatically word-aligned projections next to the human translations; they are# training material and must never enter a test set.XSID_EXCLUDED = ("projectedTrain",)142 unmodified lines"source_revision": meta["revision"],"licence": meta["licence"],"domain": meta["domain"],})if extra:record.update(extra)return record206 unmodified linesdef collect_flores_reference(targets, rows):"""Reference-only rows for languages whose test set is the non-redistributable FLORES+."""meta = SOURCE_META["flores_plus"]out = []for config in targets:if not rows[config]["in_flores_plus"]:continueiso = rows[config]["iso639_3"]for split, count in (("dev", 997), ("test", 1012)):out.append({"sl": "en", "tl": config, "id": None, "src": None, "trg": None,"split": split, "source": "flores_plus","source_url": meta["url"], "source_revision": meta["revision"],"licence": meta["licence"], "domain": meta["domain"],"text_withheld": True,"withheld_reason": "FLORES+ access terms require agreeing not to re-host it ""where web crawlers could reach it.","upstream_rows": count,"upstream_file": f"{'dev' if split == 'dev' else 'devtest'}/{iso}_*.jsonl",})return out# ------------------------------------------------------------------------------- assemblydef deduplicate(records, rows):"""Collapse records that carry the same pair, keeping the most authoritative source.2 unmodified linesorder follows which release supersedes which, mirroring the ``supersedes`` declarationsin ``configs/community_benchmarks.json``."""priority = {"nalibasid": 0, "parme": 1, "ntrex": 2, "xsid": 3, "smol": 4,"tatoeba_challenge": 5, "flores_plus": 9}best: dict[tuple, dict] = {}dropped = []for record in records:if record.get("src") is None:best[("ref", record["tl"], record["source"], record["split"])] = recordcontinuekey = (record["tl"], record["sl"], norm_key(record["src"]), norm_key(record["trg"]))26 unmodified linescolumns = ["sl", "tl", "id", "src", "trg", "is_src_orig", "split", "source","source_url", "source_revision", "licence", "domain", "source_pair","source_variant", "intent", "variety", "released_as", "upstream_id","text_withheld", "withheld_reason", "upstream_rows", "upstream_file"]schema = pa.schema([("sl", pa.string()), ("tl", pa.string()), ("id", pa.int64()),("src", pa.string()), ("trg", pa.string()), ("is_src_orig", pa.bool_()),4 unmodified lines("upstream_id", pa.int64()), ("text_withheld", pa.bool_()),("withheld_reason", pa.string()), ("upstream_rows", pa.int64()),("upstream_file", pa.string()),])summary, flat = {}, []112 unmodified lines("nalibasid", lambda: collect_nalibasid(rows)),("parme", lambda: collect_parme(rows)),("smol", lambda: collect_smol(targets, rows)),):got, missed = collector()print(f" {label:<20} {len(got):>7,} records, {len(missed)} skipped", flush=True)records += gotskipped += [{**entry, "source": label} for entry in missed]references = collect_flores_reference(targets, rows)print(f" {'flores_plus (ref)':<20} {len(references):>7,} reference rows", flush=True)60 unmodified lines6162636465666768697071727374757677787980818241 unmodified lines124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234142 unmodified lines377378379380381382383384385386387388389390391392393206 unmodified lines6006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410652 unmodified lines1068106910701071107210731074107510761077107810791080108110821083108410851086108726 unmodified lines1114111511161117111811191120112111224 unmodified lines11271128112911301131113211331134113511361137112 unmodified lines12501251125212531254125512561257125812591260126112621263126412651266126712681269127060 unmodified linesNALIBASID_REVISION = "8d66b9021c06df1ab459636a925e119b2cff20fe"NTREX_REVISION = "468c6b69c7f6a75d31d4743d9daba2af566cc18d"PARME_REVISION = "6df9269acc75377ed6be3bf2f7966c8e238a62bd"CODET_REVISION = "main"DOLMA_BITEXT_REVISION = "main"MAIBAAM_REVISION = "master"UD_MEGRELIAN_REVISION = "dev"NUSAX_REVISION = "main"# How freely a source may be passed on. The distinction is not cosmetic: a third of the# resources found for these languages carry no licence at all, and several of the best ones# are explicitly non-commercial or no-derivatives. Publishing them all under one licence# field would misrepresent every tier but the first.## 1 redistributable: a licence that permits republishing the text.# 2 restricted: republishable only under a condition that limits reuse (non-commercial).# 3 reference only: no licence stated, no-derivatives, or an explicit request not to# redistribute. Ids and counts are published; the text is withheld.TIER_REDISTRIBUTABLE, TIER_RESTRICTED, TIER_REFERENCE = 1, 2, 3SOURCE_META = {"tatoeba_challenge": {41 unmodified lines"note": "Text withheld. Access requires agreeing not to re-host FLORES+ where web ""crawlers could reach it, which a public dataset repository would do. Fetch ""it from the upstream repository after accepting its terms.","tier": TIER_REFERENCE,"restriction": "Terms forbid re-hosting where web crawlers could reach it.",},"bouquet": {"url": "https://huggingface.co/datasets/facebook/bouquet","revision": "main", "licence": "CC-BY-4.0", "domain": "mixed","note": "Human-authored sentences and paragraphs, written in the source language ""rather than translated from English, with official dev and test splits. ""Carries paragraph ids, so it is the only source here with recoverable ""document structure. Released for evaluation, not training.","tier": TIER_REDISTRIBUTABLE,},"codet": {"url": "https://github.com/mahfuzibnalam/dialect_mt","revision": CODET_REVISION, "licence": "MIT", "domain": "elicited_syntax","note": "Italian Syntactic Atlas sentences elicited from speakers in 439 localities, ""each file positionally aligned to the same 792 standard Italian sentences. ""Sparsely filled, so a locality contributes only the lines it answered.","tier": TIER_REDISTRIBUTABLE,},"dolma_bitext": {"url": "https://github.com/DOLMA-NLP/bitext-mining","revision": DOLMA_BITEXT_REVISION, "licence": "CC-BY-4.0", "domain": "mixed","note": "Manually aligned sentence pairs from published translations, by the group ""behind PARME. The licence adds one term: the data must not be used to ""reconstruct the original literary works, which sentence-level use satisfies.","tier": TIER_REDISTRIBUTABLE,},"nllb_seed": {"url": "https://github.com/facebookresearch/flores/tree/main/nllb_seed","revision": "main", "licence": "CC-BY-SA-4.0", "domain": "wiki_general","note": "Professionally translated seed sentences. A separate artefact from the ""NLLB-200 mined bitext that the baseline corpus classifies as auto_mined.","tier": TIER_REDISTRIBUTABLE,},"nusax": {"url": "https://github.com/IndoNLP/nusax","revision": NUSAX_REVISION, "licence": "CC-BY-SA-4.0", "domain": "mixed","note": "Twelve-way parallel sentences for Indonesian local languages, translated by ""native speakers, with official train/valid/test splits.","tier": TIER_REDISTRIBUTABLE,},"maibaam": {"url": "https://github.com/UniversalDependencies/UD_Bavarian-MaiBaam","revision": MAIBAAM_REVISION, "licence": "CC-BY-SA-4.0", "domain": "wiki_general","note": "English sentence translations carried as '# text_en' comments on part of ""the Bavarian treebank. Only 59 of 1,070 sentences have one.","tier": TIER_REDISTRIBUTABLE,},"ud_megrelian": {"url": "https://github.com/UniversalDependencies/UD_Megrelian-MLC","revision": UD_MEGRELIAN_REVISION, "licence": "CC-BY-SA-4.0", "domain": "mixed","note": "English translations carried as '# text_en' on the Megrelian treebank. Only ""on the dev branch; the dependency columns are empty for every token, so it ""is a translated morphology set rather than a usable treebank.","tier": TIER_REDISTRIBUTABLE,},"nsanku": {"url": "https://github.com/GhanaNLP/nsanku","revision": "main", "licence": "none stated", "domain": "religious","note": "Human Dagbani-English reference pairs used as the evaluation set of Ghana ""NLP's 43-language study. Text withheld: the repository ships no licence and ""the underlying Bible translation is a Bible society copyright.","tier": TIER_REFERENCE,"restriction": "No licence file in the repository; underlying text is copyrighted.",},"betthupferl": {"url": "https://github.com/mainlp/betthupferl","revision": "main", "licence": "none stated", "domain": "narrative","note": "Human-transcribed and human-standardised Bavarian, Swabian and East ""Franconian against Standard German. Text withheld: the archives are ""password-protected and the authors ask that the data not be redistributed.","tier": TIER_REFERENCE,"restriction": "Authors explicitly request no redistribution.",},"ladin_frontull": {"url": "https://huggingface.co/sfrontull","revision": "main", "licence": "CC-BY-NC-SA-4.0", "domain": "mixed","note": "Italian-Ladin and intra-Ladin corpora. Non-commercial, so usable for ""evaluation but not in a commercial system.","tier": TIER_RESTRICTED,"restriction": "Non-commercial use only.",},"glotstorybook": {"url": "https://huggingface.co/datasets/cis-lmu/GlotStoryBook","revision": "main", "licence": "CC-BY", "domain": "narrative","note": "African Storybook texts translated by named community translators, aligned ""to English through each story's parallel id. Licensing is per row, so only ""the plain CC-BY stories are taken.","tier": TIER_REDISTRIBUTABLE,},"ladin_weather": {"url": "https://huggingface.co/datasets/sfrontull/south-tyrol-weather-lld-deu","revision": "main", "licence": "CC-BY-SA-4.0", "domain": "weather","note": "South Tyrol meteorological office bulletins in Ladin and German, with an ""official test split. The only Ladin set paired with German rather than ""Italian.","tier": TIER_REDISTRIBUTABLE,},}for _name, _meta in SOURCE_META.items():_meta.setdefault("tier", TIER_REDISTRIBUTABLE)_meta.setdefault("restriction", None)# xSID ships automatically word-aligned projections next to the human translations; they are# training material and must never enter a test set.XSID_EXCLUDED = ("projectedTrain",)142 unmodified lines"source_revision": meta["revision"],"licence": meta["licence"],"domain": meta["domain"],"licence_tier": meta["tier"],"redistributable": meta["tier"] != TIER_REFERENCE,"licence_restriction": meta["restriction"],})if extra:record.update(extra)if meta["tier"] == TIER_REFERENCE:# Counted and attributable, but the text itself is not ours to pass on.record["src"], record["trg"] = "", ""record["text_withheld"] = Truerecord["withheld_reason"] = meta["restriction"] or "no licence stated"return record206 unmodified linesdef collect_flores_reference(targets, rows):"""Reference-only rows for languages whose test set is the non-redistributable FLORES+."""out = []for config in targets:if not rows[config]["in_flores_plus"]:continueiso = rows[config]["iso639_3"]for split, count in (("dev", 997), ("test", 1012)):# Built through make_record like every other source, so that withheld rows carry# the same tier fields and the same empty-string convention as the others rather# than a second, nearly-identical shape.out.append(make_record(pivot_config="en", target_config=config, src="", trg="",source="flores_plus", split=split,extra={"upstream_rows": count,"upstream_file":f"{'dev' if split == 'dev' else 'devtest'}/{iso}_*.jsonl"},))return out# ------------------------------------------------------------------------------- assembly# BOUQuET codes its languages with a script tag; these are the ones that matter here, both# for our targets and for the pivots they are paired with.BOUQUET_TARGETS = {"azb": "azb_Arab", "skr": "skr_Arab", "wuu": "wuu_Hans"}BOUQUET_PIVOTS = {"eng_Latn": "en", "pes_Arab": "fa", "hin_Deva": "hi", "cmn_Hans": "zh"}def collect_bouquet(targets, rows):"""BOUQuET dev and test, at sentence and paragraph level.The only source here that is not translated out of English: every passage was written inone of the languages and then translated outwards. It also carries ``par_id``, so asentence can be traced back to the paragraph it came from -- the one piece of documentstructure in the whole collection."""import pyarrow.parquet as pqfrom huggingface_hub import hf_hub_downloadfrom hf_publishing_auth import publishing_tokenout, skipped = [], []token = publishing_token()for config, tagged in BOUQUET_TARGETS.items():if config not in targets:continuefor pivot_tag, pivot_config in BOUQUET_PIVOTS.items():ok, _why = pivots.acceptable_pivot(config, pivot_config, rows)if not ok:skipped.append({"target": config, "pair": f"{pivot_tag}-{tagged}","reason": "pivot not acceptable", "source": "bouquet"})continuefor level in ("sentence_level", "paragraph_level"):for upstream, split in (("dev", "dev"), ("test", "test")):name = (f"benchmark_data/{level}/{upstream}/{pivot_tag}-{tagged}.parquet")try:path = hf_hub_download("facebook/bouquet", name,repo_type="dataset", token=token)except Exception as error: # noqa: BLE001 - absent pair or no accessskipped.append({"target": config, "pair": name,"reason": f"{type(error).__name__}","source": "bouquet"})continuetable = pq.read_table(path, columns=["src_text", "tgt_text", "par_id", "domain", "register"])for src, trg, par_id, domain, register in zip(table.column("src_text").to_pylist(),table.column("tgt_text").to_pylist(),table.column("par_id").to_pylist(),table.column("domain").to_pylist(),table.column("register").to_pylist(),):if not (src or "").strip() or not (trg or "").strip():continueout.append(make_record(pivot_config=pivot_config, target_config=config,src=src, trg=trg, source="bouquet", split=split,is_src_orig=None,extra={"source_variant": level.replace("_level", ""),"document_id": str(par_id) if par_id is not None else None,"text_domain": domain, "register": register,"released_as": "evaluation"},))return out, skipped# CODET publishes one file per locality, named for the place rather than the language, so the# mapping from place to ISO code has to be stated. Only localities whose variety is one of our# targets are listed; the atlas covers 439 in total.CODET_LOCALITIES = {"nap": ["Marcianise", "Montella", "Napoli", "Ariano%20Irpino", "Gragnano", "Salerno","Torre%20del%20Greco", "Carife", "Trevico", "Calitri", "Bagnoli%20Irpino","Montecalvo%20Irpino", "Scampitella", "Cardito1", "Cardito2", "Cardito3","Cardito4"],"lld": ["Corvara", "Selva%20di%20Val%20Gardena", "Pozza%20di%20Fassa", "Ortisei"],"pms": ["Torino", "Torino1", "Borgomanero", "Alba", "Mondovi", "Moncalieri", "Poirino","Novi%20Ligure", "Trecate", "Borgofranco%20d%27Ivrea", "Tollegno","Rivarossa%20Canavese"],"eml": ["Bologna1", "Bologna2", "Carpi", "Ferrara1", "Mantova", "Bondeno","Bagnolo%20S.%20Vito", "Casalmaggiore", "Luzzara", "Redondesco", "Campagnola","Forli", "Forl%C3%AC", "Cesena2", "Rimini"],}def collect_codet(targets, rows):"""CODET's Italian Syntactic Atlas files, aligned by line against standard Italian."""base = ("https://raw.githubusercontent.com/mahfuzibnalam/dialect_mt/"f"{CODET_REVISION}/Italian")standard = fetch(f"{base}/Standard.ita")out, skipped = [], []if not standard:return out, [{"target": None, "pair": "Standard.ita","reason": "not fetchable", "source": "codet"}]reference = standard.decode("utf-8", "replace").splitlines()ok, _why = pivots.acceptable_pivot("nap", "it", rows)if not ok:return out, [{"target": None, "pair": "it", "reason": "pivot not acceptable","source": "codet"}]for config, localities in CODET_LOCALITIES.items():if config not in targets:continuefor locality in localities:payload = fetch(f"{base}/{locality}.ita")if not payload:skipped.append({"target": config, "pair": f"{locality}.ita","reason": "not fetchable", "source": "codet"})continuelines = payload.decode("utf-8", "replace").splitlines()if len(lines) != len(reference):# Alignment here is purely positional, so a different length means the file# cannot be trusted against the standard text at all.skipped.append({"target": config, "pair": f"{locality}.ita","reason": f"{len(lines)} lines against "f"{len(reference)} standard","source": "codet"})continuename = urllib.parse.unquote(locality)for index, (dialect, italian) in enumerate(zip(lines, reference)):if not dialect.strip() or not italian.strip():continueout.append(make_record(pivot_config="it", target_config=config, src=italian, trg=dialect,source="codet", split="test", is_src_orig=True,extra={"source_variant": name, "upstream_id": index,"locality": name},))return out, skippeddef collect_dolma_bitext(targets, rows):"""DOLMA-NLP's manually aligned pairs: the first human Gilaki sentence bitext."""base = ("https://raw.githubusercontent.com/DOLMA-NLP/bitext-mining/"f"{DOLMA_BITEXT_REVISION}/datasets/manually-aligned")out, skipped = [], []for config, filename in (("glk", "GLK-EN.tsv"), ("mzn", "MZN-EN.tsv")):if config not in targets:continuepayload = fetch(f"{base}/{filename}")if not payload:skipped.append({"target": config, "pair": filename,"reason": "not fetchable", "source": "dolma_bitext"})continueok, _why = pivots.acceptable_pivot(config, "en", rows)if not ok:continuelines = payload.decode("utf-8", "replace").splitlines()for index, line in enumerate(lines[1:]): # first line is the headerparts = line.split("\t")if len(parts) < 2 or not parts[0].strip() or not parts[1].strip():continueout.append(make_record(pivot_config="en", target_config=config, src=parts[0], trg=parts[1],source="dolma_bitext", split="test", extra={"upstream_id": index},))return out, skippeddef collect_nllb_seed(targets, rows):"""NLLB-Seed's professionally translated sentences, for Buginese."""out, skipped = [], []if "bug" not in targets:return out, skippedok, _why = pivots.acceptable_pivot("bug", "en", rows)if not ok:return out, skippedpayload = fetch("https://dl.fbaipublicfiles.com/nllb/NLLB-Seed.zip")if not payload:return out, [{"target": "bug", "pair": "NLLB-Seed.zip","reason": "not fetchable", "source": "nllb_seed"}]try:archive = zipfile.ZipFile(io.BytesIO(payload))except zipfile.BadZipFile:return out, [{"target": "bug", "pair": "NLLB-Seed.zip","reason": "not a zip", "source": "nllb_seed"}]names = archive.namelist()left = next((n for n in names if n.endswith("/eng_Latn") and "bug_Latn" in n), None)right = next((n for n in names if n.endswith("/bug_Latn")), None)if not left or not right:return out, [{"target": "bug", "pair": "NLLB-Seed","reason": f"no bug_Latn/eng_Latn members among {len(names)} entries","source": "nllb_seed"}]src_lines = archive.read(left).decode("utf-8", "replace").splitlines()trg_lines = archive.read(right).decode("utf-8", "replace").splitlines()if len(src_lines) != len(trg_lines):return out, [{"target": "bug", "pair": "NLLB-Seed","reason": f"{len(src_lines)} vs {len(trg_lines)} lines","source": "nllb_seed"}]for index, (src, trg) in enumerate(zip(src_lines, trg_lines)):if not src.strip() or not trg.strip():continueout.append(make_record(pivot_config="en", target_config="bug", src=src, trg=trg,source="nllb_seed", split="test", is_src_orig=True,extra={"upstream_id": index},))return out, skippeddef collect_nusax(targets, rows):"""NusaX-MT, twelve-way parallel with official splits. Buginese is the target here."""out, skipped = [], []if "bug" not in targets:return out, skippedbase = f"https://raw.githubusercontent.com/IndoNLP/nusax/{NUSAX_REVISION}/datasets/mt"# NusaX names its columns by language; Indonesian and English are the pivots we keep.wanted = {"indonesian": "id", "english": "en"}for upstream, split in (("test", "test"), ("valid", "dev")):payload = fetch(f"{base}/{upstream}.csv")if not payload:skipped.append({"target": "bug", "pair": f"{upstream}.csv","reason": "not fetchable", "source": "nusax"})continuereader = csv.DictReader(io.StringIO(payload.decode("utf-8", "replace")))for index, row in enumerate(reader):target_text = (row.get("buginese") or "").strip()if not target_text:continuefor column, pivot_config in wanted.items():src = (row.get(column) or "").strip()if not src:continueok, _why = pivots.acceptable_pivot("bug", pivot_config, rows)if not ok:continueout.append(make_record(pivot_config=pivot_config, target_config="bug",src=src, trg=target_text, source="nusax", split=split,extra={"upstream_id": index},))return out, skipped# Treebanks that carry a free English translation per sentence as a conll comment.TREEBANK_TRANSLATIONS = {"maibaam": {"config": "bar","files": [("https://raw.githubusercontent.com/UniversalDependencies/"f"UD_Bavarian-MaiBaam/{MAIBAAM_REVISION}/bar_maibaam-ud-test.conllu","test")],},"ud_megrelian": {"config": "xmf","files": [("https://raw.githubusercontent.com/UniversalDependencies/"f"UD_Megrelian-MLC/{UD_MEGRELIAN_REVISION}/xmf_mlc_ud-test.conllu","test")],},}def collect_treebank_translations(targets, rows):"""Sentences from UD treebanks that ship a '# text_en' free translation."""out, skipped = [], []for source, spec in TREEBANK_TRANSLATIONS.items():config = spec["config"]if config not in targets:continueok, _why = pivots.acceptable_pivot(config, "en", rows)if not ok:continuefor url, split in spec["files"]:payload = fetch(url)if not payload:skipped.append({"target": config, "pair": url.rsplit("/", 1)[-1],"reason": "not fetchable", "source": source})continuetext, english, kept = None, None, 0for line in payload.decode("utf-8", "replace").splitlines():if line.startswith("# text = "):text = line[len("# text = "):].strip()elif line.startswith("# text_en = "):english = line[len("# text_en = "):].strip()elif not line.strip():if text and english:out.append(make_record(pivot_config="en", target_config=config,src=english, trg=text, source=source, split=split,extra={"upstream_id": kept},))kept += 1text, english = None, Noneif text and english:out.append(make_record(pivot_config="en", target_config=config, src=english, trg=text,source=source, split=split, extra={"upstream_id": kept},))return out, skipped# Ladin corpora published by Simon Frontull. Only the two with a stated licence are taken;# the three undated test sets on the same account state none and are left out rather than# guessed at.# Only the weather bulletins belong in a test set. The two big ``dizionar`` corpora are# lexicographic example sentences harvested from a dictionary -- 37,422 of them, which would# be a third of this release and would reward a model for reproducing dictionary glosses# rather than translating. They go to the lexicon corpus instead, which is where a reader# looking for dictionary material would expect them.LADIN_SETS = [("ladin_weather", "sfrontull/south-tyrol-weather-lld-deu", "de", "test"),]def collect_ladin(targets, rows):"""Italian-Ladin and German-Ladin corpora, including the non-commercial ones."""out, skipped = [], []if "lld" not in targets:return out, skippedimport pyarrow.parquet as pqfrom huggingface_hub import snapshot_downloadfrom hf_publishing_auth import publishing_tokenfor source, repo, pivot_config, split in LADIN_SETS:ok, _why = pivots.acceptable_pivot("lld", pivot_config, rows)if not ok:skipped.append({"target": "lld", "pair": repo,"reason": "pivot not acceptable", "source": source})continuetry:local = snapshot_download(repo, repo_type="dataset",token=publishing_token(),allow_patterns=["*.parquet", "*.jsonl"])except Exception as error: # noqa: BLE001 - gated or absentskipped.append({"target": "lld", "pair": repo,"reason": f"{type(error).__name__}", "source": source})continuefound = 0# Both the parquet and the jsonl releases wrap each pair in a single ``translation``# column keyed by language, rather than one column per language.pairs: list[dict] = []for path in sorted(Path(local).rglob("*.parquet")):table = pq.read_table(path)if "translation" in table.schema.names:pairs += table.column("translation").to_pylist()for path in sorted(Path(local).rglob("*.jsonl")):with path.open(encoding="utf-8") as handle:for line in handle:entry = json.loads(line).get("translation")if isinstance(entry, dict):pairs.append(entry)for entry in pairs:target_key = next((k for k in entry if k.startswith("lld")), None)pivot_key = next((k for k in entry if k.startswith(("ita", "deu"))), None)if not target_key or not pivot_key:continuesrc, trg = entry.get(pivot_key) or "", entry.get(target_key) or ""if not src.strip() or not trg.strip():continueout.append(make_record(pivot_config=pivot_config, target_config="lld", src=src, trg=trg,source=source, split=split,extra={"source_variant": target_key, "upstream_id": found},))found += 1if not found:skipped.append({"target": "lld", "pair": repo,"reason": "no recognisable column pair", "source": source})return out, skippeddef collect_glotstorybook(targets, rows):"""African Storybook texts, aligned to English through their parallel id.Licensing is per row rather than per dataset, so only the plain CC-BY stories are taken;the CC-BY-NC and CC-BY-NC-SA ones would silently impose a condition on the whole release."""out, skipped = [], []if "dag" not in targets:return out, skippedok, _why = pivots.acceptable_pivot("dag", "en", rows)if not ok:return out, skippedfrom huggingface_hub import hf_hub_downloadfrom hf_publishing_auth import publishing_tokentry:path = hf_hub_download("cis-lmu/GlotStoryBook", "GlotStoryBook.csv",repo_type="dataset", token=publishing_token())except Exception as error: # noqa: BLE001return out, [{"target": "dag", "pair": "GlotStoryBook.csv","reason": f"{type(error).__name__}", "source": "glotstorybook"}]with open(path, encoding="utf-8") as handle:entries = list(csv.DictReader(handle))# Each story segment is identified by its parallel id plus its position in the story.english = {(row["Parallel ID"], row["Text Number"]): row["Text"]for row in entries if row["ISO639-3"] == "eng"}for row in entries:if row["ISO639-3"] != "dag":continueif (row.get("License") or "").strip().upper().replace(" ", "-") != "CC-BY":skipped.append({"target": "dag", "pair": row.get("File Name"),"reason": f"licence {row.get('License')!r} is not plain CC-BY","source": "glotstorybook"})continuekey = (row["Parallel ID"], row["Text Number"])src = english.get(key)if not src or not (row.get("Text") or "").strip():skipped.append({"target": "dag", "pair": row.get("File Name"),"reason": "no English segment with the same parallel id","source": "glotstorybook"})continueout.append(make_record(pivot_config="en", target_config="dag", src=src, trg=row["Text"],source="glotstorybook", split="test",extra={"document_id": row["Parallel ID"],"upstream_id": int(row["Text Number"]) ifstr(row["Text Number"]).isdigit() else None,"source_variant": row.get("Story Category")},))return out, skippeddef collect_nsanku(targets, rows):"""Ghana NLP's Dagbani-English reference pairs, counted but withheld.Real human translation and already used as a published evaluation set, but the repositoryships no licence and the underlying text is a Bible society translation, so only the rowcount and provenance are published."""out, skipped = [], []if "dag" not in targets:return out, skippedok, _why = pivots.acceptable_pivot("dag", "en", rows)if not ok:return out, skippedpayload = fetch("https://raw.githubusercontent.com/GhanaNLP/nsanku/main/input/dag-eng.csv")if not payload:return out, [{"target": "dag", "pair": "input/dag-eng.csv","reason": "not fetchable", "source": "nsanku"}]reader = csv.reader(io.StringIO(payload.decode("utf-8", "replace")))rows_read = sum(1 for index, line in enumerate(reader) if index and any(line))out.append(make_record(pivot_config="en", target_config="dag", src="", trg="",source="nsanku", split="test",extra={"upstream_rows": rows_read, "upstream_file": "input/dag-eng.csv"},))return out, skippeddef deduplicate(records, rows):"""Collapse records that carry the same pair, keeping the most authoritative source.2 unmodified linesorder follows which release supersedes which, mirroring the ``supersedes`` declarationsin ``configs/community_benchmarks.json``."""# Human-authored and manually aligned sources rank above translated-out-of-English ones,# and anything redistributable ranks above a withheld duplicate of the same pair: keeping# the withheld copy would lose text we are allowed to publish.priority = {"bouquet": 0, "dolma_bitext": 1, "nalibasid": 2, "parme": 3, "codet": 4,"nllb_seed": 5, "nusax": 6, "ntrex": 7, "ladin_weather": 8,"ladin_frontull": 9, "maibaam": 10, "ud_megrelian": 11, "xsid": 12,"smol": 13, "tatoeba_challenge": 14,"glotstorybook": 15, "nsanku": 20, "betthupferl": 21, "flores_plus": 22}best: dict[tuple, dict] = {}dropped = []for record in records:if record.get("text_withheld"):# Withheld rows have no text to compare, so they are keyed by what they stand# for: one row per language, source and split.best[("ref", record["tl"], record["source"], record["split"])] = recordcontinuekey = (record["tl"], record["sl"], norm_key(record["src"]), norm_key(record["trg"]))26 unmodified linescolumns = ["sl", "tl", "id", "src", "trg", "is_src_orig", "split", "source","source_url", "source_revision", "licence", "domain", "source_pair","source_variant", "intent", "variety", "released_as", "upstream_id","text_withheld", "withheld_reason", "upstream_rows", "upstream_file","licence_tier", "redistributable", "licence_restriction", "document_id","text_domain", "register", "locality"]schema = pa.schema([("sl", pa.string()), ("tl", pa.string()), ("id", pa.int64()),("src", pa.string()), ("trg", pa.string()), ("is_src_orig", pa.bool_()),4 unmodified lines("upstream_id", pa.int64()), ("text_withheld", pa.bool_()),("withheld_reason", pa.string()), ("upstream_rows", pa.int64()),("upstream_file", pa.string()),# How freely each record may be passed on, and the structure some sources carry.("licence_tier", pa.int64()), ("redistributable", pa.bool_()),("licence_restriction", pa.string()), ("document_id", pa.string()),("text_domain", pa.string()), ("register", pa.string()),("locality", pa.string()),])summary, flat = {}, []112 unmodified lines("nalibasid", lambda: collect_nalibasid(rows)),("parme", lambda: collect_parme(rows)),("smol", lambda: collect_smol(targets, rows)),("bouquet", lambda: collect_bouquet(targets, rows)),("codet", lambda: collect_codet(targets, rows)),("dolma_bitext", lambda: collect_dolma_bitext(targets, rows)),("nllb_seed", lambda: collect_nllb_seed(targets, rows)),("nusax", lambda: collect_nusax(targets, rows)),("treebanks", lambda: collect_treebank_translations(targets, rows)),("ladin", lambda: collect_ladin(targets, rows)),("glotstorybook", lambda: collect_glotstorybook(targets, rows)),("nsanku", lambda: collect_nsanku(targets, rows)),):got, missed = collector()print(f" {label:<20} {len(got):>7,} records, {len(missed)} skipped", flush=True)records += got# Two labels cover more than one source, so the entry's own source wins.skipped += [{"source": label, **entry} for entry in missed]references = collect_flores_reference(targets, rows)print(f" {'flores_plus (ref)':<20} {len(references):>7,} reference rows", flush=True)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713"""Gather lexicons, glossaries and glossed material for the audit's shortlist languages.
The evaluation corpus answers "can this model translate?". This one answers the question thatcomes first for a language with almost no parallel text: what word-level evidence exists atall. Bilingual dictionaries, parallel wordlists, dictionary example sentences and token-levelglosses are what a translation system for these languages can actually be seeded from, andfor several of them it is the only human-curated material in existence.
Records keep the same shape as the evaluation corpus -- ``sl``, ``tl``, ``src``, ``trg`` plusprovenance -- so the two can be read with one reader. ``entry_type`` says what a row reallyis, because a dictionary headword, a multiword gloss and a full example sentence are notinterchangeable evidence:
* ``word`` a single-word headword and its translation* ``phrase`` a multiword headword or gloss* ``example_sentence`` a sentence illustrating a headword, from a dictionary* ``token_gloss`` one token of a sentence glossed into another language
Pairing follows the same pivot rule as everywhere else in this project: English, plus thehigh-resource or related neighbours that the audit found contribute materially to a language.That is why Gilaki is paired with Persian here and Ladin with Italian and German.
Licence tiers are inherited from ``build_eval_corpus``: tier 1 is republishable, tier 2 isrepublishable under a restriction (non-commercial), tier 3 is counted with the text withheld.GPL-3.0 sources are tier 2 rather than tier 1 -- Apertium's dictionaries are the largesthand-written resource for several of these languages, but a copyleft licence is a realcondition on reuse and should not be hidden inside a mixed release."""
from __future__ import annotations
import argparseimport csvimport ioimport jsonimport reimport sysimport timeimport xml.etree.ElementTree as ElementTreefrom pathlib import Path
ROOT = Path(__file__).resolve().parents[1]sys.path.insert(0, str(ROOT / "scripts"))
import shortlist_pivots as pivots # noqa: E402from build_eval_corpus import ( # noqa: E402 TIER_REDISTRIBUTABLE, TIER_REFERENCE, TIER_RESTRICTED, _clean, fetch, norm_key,)from corpus_subsets import subset_name, write_subsets # noqa: E402
DIST = ROOT / "dist" / "lexicon_corpus"
CHIKHAPO_REVISION = "main"APERTIUM_REVISION = "master"DIVITAL_REVISION = "master"GILAKI_TOP1000_REVISION = "master"
SOURCE_META = { "chikhapo": { "url": "https://huggingface.co/datasets/ec5ug/chikhapo", "revision": CHIKHAPO_REVISION, "licence": "MIT", "note": "Word-level bilingual lexicons assembled from PanLex, GATITOS and the " "Intercontinental Dictionary Series. Covers 21 of the 22 languages -- Gilaki " "is the exception, which is why it needs its own sources here.", "tier": TIER_REDISTRIBUTABLE, }, "gatitos": { "url": "https://huggingface.co/datasets/google/smol", "revision": "main", "licence": "CC-BY-4.0", "note": "Google's GATITOS bilingual lexicons: short, high-frequency, professionally " "translated token pairs.", "tier": TIER_REDISTRIBUTABLE, }, "nusax_lexicon": { "url": "https://github.com/IndoNLP/nusax", "revision": "main", "licence": "CC-BY-SA-4.0", "note": "Indonesian-Buginese wordlist from NusaX, translated by native speakers.", "tier": TIER_REDISTRIBUTABLE, }, "gilaki_top1000": { "url": "https://github.com/LordArma/Top-1000-Words-in-Gilaki", "revision": GILAKI_TOP1000_REVISION, "licence": "GPL-3.0", "note": "The thousand most frequent Gilaki words, each with a Persian and English " "equivalent and an example sentence in all three languages. One of only two " "machine-readable Gilaki lexicons found anywhere.", "tier": TIER_RESTRICTED, "restriction": "GPL-3.0: derived distributions inherit copyleft terms.", }, "apertium": { "url": "https://github.com/apertium", "revision": APERTIUM_REVISION, "licence": "GPL-3.0", "note": "Hand-written bilingual dictionaries from rule-based MT pairs. The largest " "curated bilingual lexicon for Scots and for Interlingua.", "tier": TIER_RESTRICTED, "restriction": "GPL-3.0: derived distributions inherit copyleft terms.", }, "ladin_dizionar": { "url": "https://huggingface.co/sfrontull", "revision": "main", "licence": "CC-BY-NC-SA-4.0", "note": "Example sentences from the Istitut Ladin Micurà de Rü dictionaries, for Val " "Badia and Gherdeina Ladin against Italian. Dictionary examples rather than " "running text, which is why they are here and not in the evaluation corpus.", "tier": TIER_RESTRICTED, "restriction": "Non-commercial use only.", }, "divital": { "url": "https://github.com/UniversalDependencies/UD_Alemannic-DIVITAL", "revision": DIVITAL_REVISION, "licence": "CC-BY-SA-4.0", "note": "Token-level French glosses and German lemmas on the Alsatian Low Alemannic " "treebank. Genuine interlinear glossing, paired with French rather than " "German.", "tier": TIER_REDISTRIBUTABLE, },}
for _meta in SOURCE_META.values(): _meta.setdefault("tier", TIER_REDISTRIBUTABLE) _meta.setdefault("restriction", None)
# ChiKhaPo and the audit disagree on a few codes; ChiKhaPo files are named by ISO 639-3.ISO_FOR_CONFIG = { "als": "gsw", "bat_smg": "sgs", "vo": "vol", "ie": "ile", "ia": "ina", "nv": "nav", "eml": "egl",}
def iso_of(config: str, rows: dict) -> str: return ISO_FOR_CONFIG.get(config) or (rows.get(config) or {}).get("iso639_3") or config
def make_entry(*, pivot_config, target_config, src, trg, source, entry_type, extra=None) -> dict: meta = SOURCE_META[source] record = { "sl": pivot_config, "tl": target_config, "id": None, "src": _clean(src), "trg": _clean(trg), "entry_type": entry_type, "split": "lexicon", "source": source, "source_url": meta["url"], "source_revision": meta["revision"], "licence": meta["licence"], "licence_tier": meta["tier"], "redistributable": meta["tier"] != TIER_REFERENCE, "licence_restriction": meta["restriction"], } if extra: record.update(extra) if meta["tier"] == TIER_REFERENCE: record["src"], record["trg"] = "", "" record["text_withheld"] = True return record
def _entry_type(text: str) -> str: """A headword, a multiword gloss and a sentence are different kinds of evidence.""" stripped = (text or "").strip() if not stripped: return "word" if re.search(r"[.!?؟。]\s*$", stripped) or len(stripped.split()) > 6: return "example_sentence" return "word" if len(stripped.split()) == 1 else "phrase"
# ------------------------------------------------------------------------------ collectors
def collect_chikhapo(targets, rows): """ChiKhaPo's per-language lexicons, in both directions, against English.""" from huggingface_hub import hf_hub_download from hf_publishing_auth import publishing_token
out, skipped = [], [] token = publishing_token() for config in targets: iso = iso_of(config, rows) ok, _why = pivots.acceptable_pivot(config, "en", rows) if not ok: continue for name, forward in ((f"data/{iso}_eng.jsonl", True), (f"data/eng_{iso}.jsonl", False)): try: path = hf_hub_download("ec5ug/chikhapo", name, repo_type="dataset", token=token) except Exception as error: # noqa: BLE001 - language absent from the release skipped.append({"target": config, "pair": name, "reason": f"{type(error).__name__}", "source": "chikhapo"}) continue with open(path, encoding="utf-8") as handle: for index, line in enumerate(handle): entry = json.loads(line) head = entry.get("source_word") or "" for sense, translation in enumerate(entry.get("target_translations") or []): if not head.strip() or not (translation or "").strip(): continue # Always emit as pivot -> target, whichever way the file reads. src, trg = (translation, head) if forward else (head, translation) out.append(make_entry( pivot_config="en", target_config=config, src=src, trg=trg, source="chikhapo", entry_type=_entry_type(trg), extra={"sense_index": sense, "upstream_id": index, "upstream_file": name}, )) return out, skipped
def collect_gatitos(targets, rows): """GATITOS bilingual lexicons for the languages that have one.""" out, skipped = [], [] for config in targets: iso = iso_of(config, rows) ok, _why = pivots.acceptable_pivot(config, "en", rows) if not ok: continue for code in dict.fromkeys([iso, config]): name = f"gatitos/en_{code}.jsonl" payload = fetch( f"https://huggingface.co/datasets/google/smol/resolve/main/{name}", auth=True ) if not payload: continue for index, line in enumerate(payload.decode("utf-8", "replace").splitlines()): if not line.strip(): continue entry = json.loads(line) head = entry.get("src") or "" for sense, translation in enumerate(entry.get("trgs") or []): if not head.strip() or not (translation or "").strip(): continue out.append(make_entry( pivot_config="en", target_config=config, src=head, trg=translation, source="gatitos", entry_type=_entry_type(translation), extra={"sense_index": sense, "upstream_id": index, "upstream_file": name}, )) break else: skipped.append({"target": config, "pair": f"gatitos/en_{iso}.jsonl", "reason": "no GATITOS lexicon", "source": "gatitos"}) return out, skipped
def collect_nusax_lexicon(targets, rows): """NusaX's Indonesian-Buginese wordlist.""" out, skipped = [], [] if "bug" not in targets: return out, skipped ok, _why = pivots.acceptable_pivot("bug", "id", rows) if not ok: return out, skipped payload = fetch("https://raw.githubusercontent.com/IndoNLP/nusax/main/" "datasets/lexicon/buginese.csv") if not payload: return out, [{"target": "bug", "pair": "lexicon/buginese.csv", "reason": "not fetchable", "source": "nusax_lexicon"}] reader = csv.reader(io.StringIO(payload.decode("utf-8", "replace"))) for index, line in enumerate(reader): if index == 0 or len(line) < 2: continue indonesian, buginese = line[0].strip(), line[1].strip() if not indonesian or not buginese: continue out.append(make_entry( pivot_config="id", target_config="bug", src=indonesian, trg=buginese, source="nusax_lexicon", entry_type=_entry_type(buginese), extra={"upstream_id": index}, )) return out, skipped
def collect_gilaki_top1000(targets, rows): """The Gilaki frequency list: words and example sentences against Persian and English.""" out, skipped = [], [] if "glk" not in targets: return out, skipped # The default branch is master, not main, and the filename contains spaces. name = "Top%201000%20Words%20in%20Gilaki.json" payload = fetch("https://raw.githubusercontent.com/LordArma/Top-1000-Words-in-Gilaki/" f"{GILAKI_TOP1000_REVISION}/JSON/{name}") if not payload: return out, [{"target": "glk", "pair": name, "reason": "not fetchable", "source": "gilaki_top1000"}] try: entries = json.loads(payload.decode("utf-8", "replace")) except json.JSONDecodeError as error: return out, [{"target": "glk", "pair": name, "reason": f"invalid JSON: {error}", "source": "gilaki_top1000"}]
def value(entry, key): got = entry.get(key) return got.strip() if isinstance(got, str) else ""
for entry in entries: if not isinstance(entry, dict): continue gilaki = value(entry, "glk_word") gilaki_example = value(entry, "glk_example") index = entry.get("id") for pivot_config, prefix in (("fa", "fa"), ("en", "en")): ok, _why = pivots.acceptable_pivot("glk", pivot_config, rows) if not ok: continue word = value(entry, f"{prefix}_word") if gilaki and word: out.append(make_entry( pivot_config=pivot_config, target_config="glk", src=word, trg=gilaki, source="gilaki_top1000", entry_type="word", extra={"upstream_id": index, "upstream_file": "JSON/" + name}, )) # The example sentences are the more valuable half: real Gilaki syntax, and the # only Gilaki-Persian sentence pairs in this corpus. example = value(entry, f"{prefix}_example") if gilaki_example and example: out.append(make_entry( pivot_config=pivot_config, target_config="glk", src=example, trg=gilaki_example, source="gilaki_top1000", entry_type="example_sentence", extra={"upstream_id": index, "upstream_file": "JSON/" + name}, )) return out, skipped
# Apertium bilingual dictionaries worth taking, as (repo, left code, right code). Only pairs# where one side is a shortlist language and the other is an acceptable pivot.APERTIUM_PAIRS = [ ("apertium-eng-sco", "eng", "sco", "sco", "en"), ("apertium-eng-ina", "eng", "ina", "ia", "en"), ("apertium-spa-ina", "spa", "ina", "ia", "es"), ("apertium-fra-ina", "fra", "ina", "ia", "fr"), ("apertium-por-ina", "por", "ina", "ia", "pt"), ("apertium-deu-ina", "deu", "ina", "ia", "de"), ("apertium-cat-ina", "cat", "ina", "ia", "ca"), ("apertium-ron-ina", "ron", "ina", "ia", "ro"),]
def _dix_pairs(payload: bytes, left: str, right: str) -> list[tuple[str, str]]: """Left/right pairs from an Apertium bilingual dictionary.""" try: tree = ElementTree.fromstring(payload) except ElementTree.ParseError: return [] pairs = [] for entry in tree.iter("e"): pair = entry.find("p") if pair is None: # A shared-form entry: one <i> standing for both sides. shared = entry.find("i") if shared is not None: text = "".join(shared.itertext()).strip() if text: pairs.append((text, text)) continue left_node, right_node = pair.find("l"), pair.find("r") if left_node is None or right_node is None: continue left_text = "".join(left_node.itertext()).strip() right_text = "".join(right_node.itertext()).strip() if left_text and right_text: pairs.append((left_text, right_text)) return pairs
def collect_apertium(targets, rows): """Hand-written Apertium bilingual dictionaries.""" out, skipped = [], [] for repo, left, right, config, pivot_config in APERTIUM_PAIRS: if config not in targets: continue ok, _why = pivots.acceptable_pivot(config, pivot_config, rows) if not ok: skipped.append({"target": config, "pair": repo, "reason": "pivot not acceptable", "source": "apertium"}) continue name = f"{repo}.{left}-{right}.dix" payload = fetch(f"https://raw.githubusercontent.com/apertium/{repo}/" f"{APERTIUM_REVISION}/{name}") if not payload: skipped.append({"target": config, "pair": name, "reason": "not fetchable", "source": "apertium"}) continue found = _dix_pairs(payload, left, right) if not found: skipped.append({"target": config, "pair": name, "reason": "no parsable entries", "source": "apertium"}) continue for index, (pivot_word, target_word) in enumerate(found): out.append(make_entry( pivot_config=pivot_config, target_config=config, src=pivot_word, trg=target_word, source="apertium", entry_type=_entry_type(target_word), extra={"upstream_id": index, "upstream_file": name}, )) return out, skipped
LADIN_DICTIONARIES = [ ("sfrontull/lld_valbadia-ita", "it"), ("sfrontull/lld_gherd-ita", "it"), ("sfrontull/lld_valbadia-lld_gherd", "lld"),]
def collect_ladin_dizionar(targets, rows): """Dictionary example sentences for the two main Ladin varieties.""" out, skipped = [], [] if "lld" not in targets: return out, skipped import pyarrow.parquet as pq from huggingface_hub import snapshot_download from hf_publishing_auth import publishing_token
for repo, pivot_config in LADIN_DICTIONARIES: if pivot_config != "lld": ok, _why = pivots.acceptable_pivot("lld", pivot_config, rows) if not ok: skipped.append({"target": "lld", "pair": repo, "reason": "pivot not acceptable", "source": "ladin_dizionar"}) continue try: local = snapshot_download(repo, repo_type="dataset", token=publishing_token(), allow_patterns=["*.parquet"]) except Exception as error: # noqa: BLE001 skipped.append({"target": "lld", "pair": repo, "reason": f"{type(error).__name__}", "source": "ladin_dizionar"}) continue found = 0 for path in sorted(Path(local).rglob("*.parquet")): table = pq.read_table(path) if "translation" not in table.schema.names: continue for entry in table.column("translation").to_pylist(): if not isinstance(entry, dict): continue keys = sorted(entry) if pivot_config == "lld": # The intra-Ladin set: Val Badia against Gherdeina. pivot_key = next((k for k in keys if k.endswith("gherd")), None) target_key = next((k for k in keys if k.endswith("valbadia")), None) else: pivot_key = next((k for k in keys if k.startswith(("ita", "deu"))), None) target_key = next((k for k in keys if k.startswith("lld")), None) if not pivot_key or not target_key: continue src, trg = entry.get(pivot_key) or "", entry.get(target_key) or "" if not src.strip() or not trg.strip(): continue out.append(make_entry( pivot_config=pivot_config, target_config="lld", src=src, trg=trg, source="ladin_dizionar", entry_type=_entry_type(trg), extra={"upstream_id": found, "source_variant": target_key, "upstream_file": repo}, )) found += 1 if not found: skipped.append({"target": "lld", "pair": repo, "reason": "no translation column", "source": "ladin_dizionar"}) return out, skipped
def collect_divital(targets, rows): """Token-level French glosses from the Alsatian Low Alemannic treebank.""" out, skipped = [], [] if "als" not in targets: return out, skipped ok, _why = pivots.acceptable_pivot("als", "fr", rows) if not ok: skipped.append({"target": "als", "pair": "DIVITAL", "reason": "pivot not acceptable", "source": "divital"}) return out, skipped payload = fetch("https://raw.githubusercontent.com/UniversalDependencies/" f"UD_Alemannic-DIVITAL/{DIVITAL_REVISION}/gsw_divital-ud-test.conllu") if not payload: return out, [{"target": "als", "pair": "gsw_divital-ud-test.conllu", "reason": "not fetchable", "source": "divital"}] for index, line in enumerate(payload.decode("utf-8", "replace").splitlines()): if not line.strip() or line.startswith("#"): continue fields = line.split("\t") if len(fields) < 10: continue form, misc = fields[1], fields[9] gloss = None for item in misc.split("|"): if item.startswith("Gloss[fr]="): gloss = item[len("Gloss[fr]="):] break if not form.strip() or not gloss or not gloss.strip(): continue out.append(make_entry( pivot_config="fr", target_config="als", src=gloss, trg=form, source="divital", entry_type="token_gloss", extra={"upstream_id": index}, )) return out, skipped
# ------------------------------------------------------------------- de-duplication & output
def deduplicate(entries): """Collapse identical pairs, keeping the most freely licensed copy.
The same PanLex-derived pair reaches us through ChiKhaPo and GATITOS, and the Apertium dictionaries overlap both. Keeping the tier-1 copy matters: preferring a GPL or non-commercial duplicate would impose its condition on data we could otherwise publish freely. """ best: dict[tuple, dict] = {} dropped = [] for entry in entries: key = (entry["tl"], entry["sl"], norm_key(entry["src"]), norm_key(entry["trg"])) incumbent = best.get(key) if incumbent is None: best[key] = entry continue if entry["licence_tier"] < incumbent["licence_tier"]: dropped.append({"kept": entry["source"], "dropped": incumbent["source"], "language": entry["tl"]}) best[key] = entry else: dropped.append({"kept": incumbent["source"], "dropped": entry["source"], "language": entry["tl"]}) return list(best.values()), dropped
COLUMNS = ["sl", "tl", "id", "src", "trg", "entry_type", "split", "source", "source_url", "source_revision", "licence", "licence_tier", "redistributable", "licence_restriction", "sense_index", "upstream_id", "upstream_file", "source_variant", "text_withheld"]
def arrow_schema(): import pyarrow as pa
return pa.schema([ ("sl", pa.string()), ("tl", pa.string()), ("id", pa.int64()), ("src", pa.string()), ("trg", pa.string()), ("entry_type", pa.string()), ("split", pa.string()), ("source", pa.string()), ("source_url", pa.string()), ("source_revision", pa.string()), ("licence", pa.string()), ("licence_tier", pa.int64()), ("redistributable", pa.bool_()), ("licence_restriction", pa.string()), ("sense_index", pa.int64()), ("upstream_id", pa.int64()), ("upstream_file", pa.string()), ("source_variant", pa.string()), ("text_withheld", pa.bool_()), ])
def write_release(entries, skipped, dropped, selection, rows, release_id=None): import pyarrow as pa import pyarrow.parquet as pq
release_id = release_id or time.strftime("lexicon_%Y%m%dT%H%M%SZ", time.gmtime()) output = DIST / release_id (output / "languages").mkdir(parents=True, exist_ok=True)
by_language: dict[str, list[dict]] = {} for entry in entries: by_language.setdefault(entry["tl"], []).append(entry)
flat = [] languages = {} for config in selection["languages"]: items = by_language.get(config, []) items.sort(key=lambda e: (e["source"], e["sl"], e.get("upstream_id") or 0, e.get("sense_index") or 0)) for index, entry in enumerate(items): entry["id"] = index path = output / "languages" / f"{config}.jsonl" with path.open("w", encoding="utf-8") as handle: for entry in items: handle.write(json.dumps(entry, ensure_ascii=False) + "\n") by_source: dict[str, int] = {} by_type: dict[str, int] = {} for entry in items: by_source[entry["source"]] = by_source.get(entry["source"], 0) + 1 by_type[entry["entry_type"]] = by_type.get(entry["entry_type"], 0) + 1 languages[config] = { "language_name": selection["languages"][config]["language_name"], "iso639_3": selection["languages"][config]["iso639_3"], "entries": len(items), "redistributable_entries": sum(1 for e in items if e["redistributable"] and e["licence_tier"] == TIER_REDISTRIBUTABLE), "pivots": sorted({e["sl"] for e in items}), "sources": sorted(by_source), "by_source": by_source, "by_entry_type": by_type, } flat += items
table = pa.Table.from_pylist( [{column: entry.get(column) for column in COLUMNS} for entry in flat], schema=arrow_schema(), ) pq.write_table(table, output / "lexicon.parquet", compression="zstd")
def as_table(items): return pa.Table.from_pylist( [{column: entry.get(column) for column in COLUMNS} for entry in items], schema=arrow_schema(), )
# Same subset scheme as the other two corpora: everything, plus one per source and # language, so a reader can take exactly the lexicon they trust. subsets = {"all": list(flat)} for source, language in sorted({(e["source"], e["tl"]) for e in flat}): subsets[subset_name(source, language)] = [ e for e in flat if e["source"] == source and e["tl"] == language ] subset_report = write_subsets(output, subsets, as_table, split="lexicon")
tiers: dict[str, int] = {} for entry in flat: tiers[str(entry["licence_tier"])] = tiers.get(str(entry["licence_tier"]), 0) + 1
manifest = { "release_id": release_id, "built_at": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()), "audit_release": selection["release"], "shortlist_count": len(selection["languages"]), "total_entries": len(flat), "languages_with_entries": sum(1 for v in languages.values() if v["entries"]), "languages_without_entries": sorted( c for c, v in languages.items() if not v["entries"] ), "entries_by_licence_tier": tiers, "licence": "CC-BY-SA-4.0", "licence_note": ( "Share-alike, forced by the CC-BY-SA sources. Per-record 'licence', " "'licence_tier' and 'licence_restriction' say what each row actually permits: " "tier 1 is freely republishable, tier 2 carries a restriction (non-commercial or " "GPL copyleft), tier 3 is counted with the text withheld. Filter on " "licence_tier = 1 for a release with no further conditions." ), "entry_types": { "word": "a single-word headword and its translation", "phrase": "a multiword headword or gloss", "example_sentence": "a sentence illustrating a headword, from a dictionary", "token_gloss": "one token of a sentence glossed into another language", }, "sources": { name: {k: v for k, v in meta.items()} for name, meta in SOURCE_META.items() }, "languages": languages, "subsets": subset_report, "subset_note": ( "'all' is every entry. The rest are <source>-<language>: where the entries came " "from, and which language they are for." ), "duplicates_collapsed": len(dropped), "skipped": skipped, "columns": COLUMNS, } (output / "manifest.json").write_text( json.dumps(manifest, ensure_ascii=False, indent=1) + "\n", encoding="utf-8" ) return output, manifest
def build(release_id=None): selection = pivots.selection() rows = pivots.load_rows(pivots.DIST / selection["release"]) targets = list(selection["languages"])
entries, skipped = [], [] for label, collector in ( ("chikhapo", lambda: collect_chikhapo(targets, rows)), ("gatitos", lambda: collect_gatitos(targets, rows)), ("nusax_lexicon", lambda: collect_nusax_lexicon(targets, rows)), ("gilaki_top1000", lambda: collect_gilaki_top1000(targets, rows)), ("apertium", lambda: collect_apertium(targets, rows)), ("ladin_dizionar", lambda: collect_ladin_dizionar(targets, rows)), ("divital", lambda: collect_divital(targets, rows)), ): got, missed = collector() print(f" {label:<18} {len(got):>8,} entries, {len(missed)} skipped", flush=True) entries += got skipped += [{"source": label, **entry} for entry in missed]
entries, dropped = deduplicate(entries) print(f" deduplicated: {len(dropped):,} collapsed -> {len(entries):,} entries") output, manifest = write_release(entries, skipped, dropped, selection, rows, release_id) print(f"\nrelease: {output}") print(f"languages with entries: {manifest['languages_with_entries']}/" f"{manifest['shortlist_count']}") print(f"entries: {manifest['total_entries']:,} " f"by licence tier: {manifest['entries_by_licence_tier']}") if manifest["languages_without_entries"]: print(f"no lexicon: {manifest['languages_without_entries']}") return output, manifest
def main(argv=None) -> int: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--release-id", default=None) args = parser.parse_args(argv) build(args.release_id) return 0
if __name__ == "__main__": raise SystemExit(main())44 unmodified lines45464748495052 unmodified lines103104105106107108253 unmodified lines36236336436536636736834 unmodified lines40340440540640740840944 unmodified lines"pretty": "Existing parallel training data for under-served languages","tags": ["machine-translation", "parallel-corpus", "low-resource", "baseline"],},}52 unmodified linesreturn rows, len(pairs)def eval_card(manifest: dict, target: dict) -> str:pair_rows, pair_count = subset_table(manifest)languages = manifest["languages"]253 unmodified linesdef stage(release: Path, target: dict, kind: str) -> dict:"""Lay out the files to upload and the card, without touching the release directory."""manifest = json.loads((release / "manifest.json").read_text(encoding="utf-8"))card = (eval_card if kind == "eval" else baseline_card)(manifest, target)uploads = {f"data/{target['parquet']}": release / target["parquet"],"manifest.json": release / "manifest.json",34 unmodified lines"dataset_id": target["dataset_id"],"files": len(staged["uploads"]) + 1,"rows": rows,"records": staged["manifest"]["total_records"],"bytes": sum(p.stat().st_size for p in staged["uploads"].values()),"checksums": {name: _sha256(path)[:16] for name, path in staged["uploads"].items()},}44 unmodified lines45464748495051525354555657585952 unmodified lines112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235253 unmodified lines48949049149249349449549634 unmodified lines53153253353453553653753853944 unmodified lines"pretty": "Existing parallel training data for under-served languages","tags": ["machine-translation", "parallel-corpus", "low-resource", "baseline"],},"lexicon": {"dataset_id": "sigiranic/underserved-translation-lexicons","root": ROOT / "dist" / "lexicon_corpus","glob": "lexicon_*","parquet": "lexicon.parquet","split": "lexicon","pretty": "Lexicons, glossaries and glosses for under-served languages","tags": ["machine-translation", "lexicon", "low-resource", "bilingual-dictionary"],},}52 unmodified linesreturn rows, len(pairs)def lexicon_card(manifest: dict, target: dict) -> str:subset_rows, subset_count = subset_table(manifest)languages = manifest["languages"]ranked = sorted(languages.items(), key=lambda kv: -kv[1]["entries"])rows = "\n".join(f"| `{config}` | {entry['language_name']} | {entry['entries']:,} | "f"{entry['redistributable_entries']:,} | {', '.join(entry['pivots'])} | "f"{', '.join(entry['sources'])} |"for config, entry in ranked)sources = "\n".join(f"| [{name}]({meta['url']}) | `{str(meta['revision'])[:12]}` | {meta['licence']} | "f"tier {meta['tier']} | {meta['note']} |"for name, meta in sorted(manifest["sources"].items()))types = "\n".join(f"| `{name}` | {description} |"for name, description in manifest["entry_types"].items())tiers = manifest["entries_by_licence_tier"]return f"""---license: cc-by-sa-4.0task_categories:- translationpretty_name: {target['pretty']}size_categories:- 100K<n<1Mtags:{chr(10).join(f'- {tag}' for tag in target['tags'])}{config_block(manifest)}---# {target['pretty']}Bilingual dictionaries, parallel wordlists, dictionary example sentences and token-levelglosses for the {manifest['shortlist_count']} languages shortlisted by[sigiranic/language-status](https://huggingface.co/datasets/sigiranic/language-status).For several of these languages this is the only human-curated translation evidence thatexists. It is the material a system can be seeded from when there is almost no parallel textto train on, and it is deliberately kept separate from the two sentence-level corpora:- [sigiranic/underserved-translation-eval](https://huggingface.co/datasets/sigiranic/underserved-translation-eval) — human test sets- [sigiranic/underserved-translation-baseline](https://huggingface.co/datasets/sigiranic/underserved-translation-baseline) — existing training data**{manifest['total_entries']:,} entries** across {manifest['languages_with_entries']} of{manifest['shortlist_count']} languages.## What a row isRows use the same `sl`/`tl`/`src`/`trg` shape as the other two corpora, so one reader handlesall three. `entry_type` says what the row actually is, because these are not interchangeablekinds of evidence:| `entry_type` | meaning ||---|---|{types}## Licence tiers{manifest['licence_note']}| tier | entries ||---|--:|| 1 — freely republishable | {tiers.get('1', 0):,} || 2 — republishable with a restriction | {tiers.get('2', 0):,} || 3 — counted, text withheld | {tiers.get('3', 0):,} |```pythonfrom datasets import load_dataset# Everything.lex = load_dataset("{target['dataset_id']}", "all", split="lexicon")# Only entries with no further conditions attached.free = lex.filter(lambda row: row["licence_tier"] == 1)# Only real sentences, not headwords.examples = lex.filter(lambda row: row["entry_type"] == "example_sentence")```## Languages| config | language | entries | tier 1 | pivots | sources ||---|---|--:|--:|---|---|{rows}## Sources| source | revision | licence | tier | what it is ||---|---|---|---|---|{sources}## Subsets`all` is every entry. The other {subset_count} are `<source>-<language>`: where the entriescame from, and which language they are for.| subset | entries | splits ||---|--:|---|{subset_rows}## Caveats- A dictionary headword is not a sentence. Training on `word` rows teaches vocabulary, notsyntax; only the `example_sentence` and `token_gloss` rows carry structure.- Many entries reach this release through PanLex, so ChiKhaPo, GATITOS and Apertium overlap.Duplicates are collapsed on the normalised pair, keeping the most freely licensed copy.- Entry counts are not quality. A language with thousands of entries from one aggregatedsource may have had less human curation than one with a few hundred hand-written ones.- Gilaki is absent from ChiKhaPo entirely, so its entries come from a single GPL-3.0 source.That makes it the one language here with no tier-1 lexicon at all.Built by `scripts/build_lexicon_corpus.py`; release `{manifest['release_id']}`, derived fromaudit release `{manifest['audit_release']}`."""def eval_card(manifest: dict, target: dict) -> str:pair_rows, pair_count = subset_table(manifest)languages = manifest["languages"]253 unmodified linesdef stage(release: Path, target: dict, kind: str) -> dict:"""Lay out the files to upload and the card, without touching the release directory."""manifest = json.loads((release / "manifest.json").read_text(encoding="utf-8"))card = {"eval": eval_card, "baseline": baseline_card,"lexicon": lexicon_card}[kind](manifest, target)uploads = {f"data/{target['parquet']}": release / target["parquet"],"manifest.json": release / "manifest.json",34 unmodified lines"dataset_id": target["dataset_id"],"files": len(staged["uploads"]) + 1,"rows": rows,# The sentence corpora count "records"; the lexicon counts "entries"."records": staged["manifest"].get("total_records")or staged["manifest"]["total_entries"],"bytes": sum(p.stat().st_size for p in staged["uploads"].values()),"checksums": {name: _sha256(path)[:16] for name, path in staged["uploads"].items()},}
50 unmodified lines51525354555612 unmodified lines697071727374751 unmodified line77787980818225 unmodified lines10810911011111211311411511611711811912012112218 unmodified lines14114214314414514617 unmodified lines16416516616716816913 unmodified lines1831841851861871881891902 unmodified lines1931941951961971987 unmodified lines20620720820921021121250 unmodified lines"Gathers the human-written test sets for the shortlist into the evaluation dataset."),("scripts/build_baseline_corpus.py","Downloads the existing OPUS and Tatoeba training data as the comparison baseline."),("scripts/corpus_subsets.py","Shared subset writer used by both corpus builders (<source>-<language> configs)."),("scripts/stage_audit_extras.py",12 unmodified lines("tests/test_lang_audit.py","Tests for the audit: code resolution, prefix collisions, thresholds, derived columns."),("tests/test_eval_corpus.py","Tests for both corpus builders: parsing, pivots, de-duplication, contamination."),]TEST_COMMAND = ".venv-publish/bin/python -m unittest discover -s tests -q"1 unmodified line# Where the companion datasets live, so the published list is navigable.EVAL_DATASET = "sigiranic/underserved-translation-eval"BASELINE_DATASET = "sigiranic/underserved-translation-baseline"def _sha256(path: Path) -> str:25 unmodified linesselection = shortlist_pivots.selection(release)evaluation = _corpus_manifest("eval_corpus/eval_*")baseline = _corpus_manifest("baseline_corpus/baseline_*")eval_langs = evaluation.get("languages", {})base_langs = baseline.get("languages", {})languages = []for config, entry in selection["languages"].items():row = rows[config]got = eval_langs.get(config, {})had = base_langs.get(config, {})languages.append({"finewiki_config": config,"iso639_3": entry["iso639_3"],18 unmodified lines"sources": got.get("sources", []),"by_source": got.get("by_source", {}),},"baseline": {"records": had.get("records", 0),"human_records": had.get("human_records", 0),17 unmodified lines"baseline_release": baseline.get("release_id"),"evaluation_dataset": EVAL_DATASET,"baseline_dataset": BASELINE_DATASET,"count": len(languages),"with_evaluation_data": sum(1 for entry in languages if entry["evaluation"]["records"]),"without_any_test_data": without,13 unmodified linesf"{data['count']} languages, {data['with_evaluation_data']} of them with ""evaluation data.","","| # | config | ISO | language | family | articles | pivots | eval | baseline | human baseline |","|--:|---|---|---|---|--:|---|--:|--:|--:|",]for entry in data["languages"]:lines.append(2 unmodified linesf"| {entry['family_name'] or '—'} | {entry['finewiki_articles']:,} "f"| {', '.join(f'`{code}`' for code in entry['pivots'])} "f"| {entry['evaluation']['records']:,} "f"| {entry['baseline']['records']:,} "f"| {entry['baseline']['human_records']:,} |")7 unmodified lines]lines += ["","`eval` and `baseline` are record counts in "f"[{data['evaluation_dataset']}](https://huggingface.co/datasets/{data['evaluation_dataset']}) "f"and [{data['baseline_dataset']}](https://huggingface.co/datasets/{data['baseline_dataset']}). ""`human baseline` is the part of the baseline written by people rather than "50 unmodified lines515253545556575812 unmodified lines7172737475767778791 unmodified line8182838485868725 unmodified lines11311411511611711811912012112212312412512612712812913018 unmodified lines14915015115215315415515615715815916017 unmodified lines17817918018118218318418513 unmodified lines1992002012022032042052062072 unmodified lines2102112122132142152167 unmodified lines22422522622722822923050 unmodified lines"Gathers the human-written test sets for the shortlist into the evaluation dataset."),("scripts/build_baseline_corpus.py","Downloads the existing OPUS and Tatoeba training data as the comparison baseline."),("scripts/build_lexicon_corpus.py","Gathers bilingual dictionaries, wordlists and token glosses into the lexicon dataset."),("scripts/corpus_subsets.py","Shared subset writer used by both corpus builders (<source>-<language> configs)."),("scripts/stage_audit_extras.py",12 unmodified lines("tests/test_lang_audit.py","Tests for the audit: code resolution, prefix collisions, thresholds, derived columns."),("tests/test_eval_corpus.py","Tests for the sentence corpora: parsing, pivots, de-duplication, contamination."),("tests/test_lexicon_corpus.py","Tests for the lexicon corpus and the licence tiering both corpora share."),]TEST_COMMAND = ".venv-publish/bin/python -m unittest discover -s tests -q"1 unmodified line# Where the companion datasets live, so the published list is navigable.EVAL_DATASET = "sigiranic/underserved-translation-eval"BASELINE_DATASET = "sigiranic/underserved-translation-baseline"LEXICON_DATASET = "sigiranic/underserved-translation-lexicons"def _sha256(path: Path) -> str:25 unmodified linesselection = shortlist_pivots.selection(release)evaluation = _corpus_manifest("eval_corpus/eval_*")baseline = _corpus_manifest("baseline_corpus/baseline_*")lexicon = _corpus_manifest("lexicon_corpus/lexicon_*")eval_langs = evaluation.get("languages", {})base_langs = baseline.get("languages", {})lex_langs = lexicon.get("languages", {})languages = []for config, entry in selection["languages"].items():row = rows[config]got = eval_langs.get(config, {})had = base_langs.get(config, {})words = lex_langs.get(config, {})languages.append({"finewiki_config": config,"iso639_3": entry["iso639_3"],18 unmodified lines"sources": got.get("sources", []),"by_source": got.get("by_source", {}),},"lexicon": {"entries": words.get("entries", 0),"redistributable_entries": words.get("redistributable_entries", 0),"sources": words.get("sources", []),"by_entry_type": words.get("by_entry_type", {}),},"baseline": {"records": had.get("records", 0),"human_records": had.get("human_records", 0),17 unmodified lines"baseline_release": baseline.get("release_id"),"evaluation_dataset": EVAL_DATASET,"baseline_dataset": BASELINE_DATASET,"lexicon_dataset": LEXICON_DATASET,"lexicon_release": lexicon.get("release_id"),"count": len(languages),"with_evaluation_data": sum(1 for entry in languages if entry["evaluation"]["records"]),"without_any_test_data": without,13 unmodified linesf"{data['count']} languages, {data['with_evaluation_data']} of them with ""evaluation data.","","| # | config | ISO | language | family | articles | pivots | eval | lexicon | ""baseline | human baseline |","|--:|---|---|---|---|--:|---|--:|--:|--:|--:|",]for entry in data["languages"]:lines.append(2 unmodified linesf"| {entry['family_name'] or '—'} | {entry['finewiki_articles']:,} "f"| {', '.join(f'`{code}`' for code in entry['pivots'])} "f"| {entry['evaluation']['records']:,} "f"| {entry['lexicon']['entries']:,} "f"| {entry['baseline']['records']:,} "f"| {entry['baseline']['human_records']:,} |")7 unmodified lines]lines += ["","`eval`, `lexicon` and `baseline` are counts in "f"[{data['evaluation_dataset']}](https://huggingface.co/datasets/{data['evaluation_dataset']}) "f"and [{data['baseline_dataset']}](https://huggingface.co/datasets/{data['baseline_dataset']}). ""`human baseline` is the part of the baseline written by people rather than "
1234567891011121314151617181945 unmodified lines65666768697048 unmodified lines11912012112212312412512612712812913013113213313444 unmodified lines1791801811821831841851861871881891901911922 unmodified lines19519619719819920020142 unmodified lines24424524624724824945 unmodified lines2952962972982993003013023033043053063073083093103113123133141 unmodified line31631731831932032132238 unmodified lines36136236336436536636736836937037137237337437537642 unmodified lines41942042142242342446 unmodified lines47147247347447547647747847948048148248348448548648748859 unmodified lines54854955055155255351 unmodified lines6056066076086096106116126136146156166176186196206216222 unmodified lines62562662762862963063130 unmodified lines66266366466566666743 unmodified lines71171271371471571671771871972072172272372472572672772872973053 unmodified lines78478578678778878952 unmodified lines84284384484584684741 unmodified lines8898908918928938948958968978988999009019029035 unmodified lines90991091191291391491531 unmodified lines94794894995095195237 unmodified lines990991992993994995996997998999100010011002100345 unmodified lines10491050105110521053105450 unmodified lines11051106110711081109111011111112111311141115111611171118111911201 unmodified line112211231124112511261127112829 unmodified lines1158115911601161116211631164116511661167116839 unmodified lines12081209121012111212121347 unmodified lines12611262126312641265126612671268126912701271{"description": "The languages this audit selected for low-resource translation work: a Wikipedia large enough to mine but not already saturated, at least one reachable human test set, and no Google or Microsoft Translator support. Ordered by opportunity_rank. Each entry also records the pivot languages chosen for it and how much evaluation and baseline data was actually found.","audit_release": "finewiki_audit_20261114T182048Z","evaluation_release": "eval_20261114T202652Z","baseline_release": "baseline_20261114T221020Z","evaluation_dataset": "sigiranic/underserved-translation-eval","baseline_dataset": "sigiranic/underserved-translation-baseline","count": 22,"with_evaluation_data": 17,"without_any_test_data": ["azb","bug","dag","skr","wuu"],"pivot_rule": "The audit's shortlist languages and the pivot languages worth pairing each one with.","languages": [{45 unmodified lines"xsid": 1389}},"baseline": {"records": 182,"human_records": 4,48 unmodified lines]},"evaluation": {"records": 56,"test": 56,"dev": 0,"sources": ["tatoeba_challenge"],"by_source": {"tatoeba_challenge": 56}},"baseline": {"records": 4431,"human_records": 107,44 unmodified lines]},"evaluation": {"records": 0,"test": 0,"dev": 0,"sources": [],"by_source": {}},"baseline": {"records": 9835,"human_records": 0,"human_share": 0.0,"corpora": [2 unmodified lines],"by_corpus_type": {"ui_strings": 7004,"auto_mined": 2831}}},42 unmodified lines"tatoeba_challenge": 39}},"baseline": {"records": 2894,"human_records": 0,45 unmodified lines]},"evaluation": {"records": 4863,"test": 2863,"dev": 2000,"sources": ["parme","smol"],"by_source": {"parme": 4000,"smol": 863}},"baseline": {"records": 1678,"human_records": 0,"human_share": 0.0,"corpora": [1 unmodified line"wikimedia"],"by_corpus_type": {"ui_strings": 984,"auto_mined": 694}}38 unmodified lines]},"evaluation": {"records": 754,"test": 754,"dev": 0,"sources": ["tatoeba_challenge"],"by_source": {"tatoeba_challenge": 754}},"baseline": {"records": 23625,"human_records": 0,42 unmodified lines"tatoeba_challenge": 3388}},"baseline": {"records": 7294,"human_records": 2217,46 unmodified lines]},"evaluation": {"records": 695,"test": 450,"dev": 245,"sources": ["tatoeba_challenge","xsid"],"by_source": {"tatoeba_challenge": 2,"xsid": 693}},"baseline": {"records": 11342,"human_records": 31,59 unmodified lines"parme": 4000}},"baseline": {"records": 5654,"human_records": 0,51 unmodified lines]},"evaluation": {"records": 395,"test": 395,"dev": 0,"sources": ["tatoeba_challenge"],"by_source": {"tatoeba_challenge": 395}},"baseline": {"records": 967,"human_records": 0,"human_share": 0.0,"corpora": [2 unmodified lines],"by_corpus_type": {"auto_mined": 550,"ui_strings": 417}}},30 unmodified lines"tatoeba_challenge": 2077}},"baseline": {"records": 2100,"human_records": 48,43 unmodified lines]},"evaluation": {"records": 2940,"test": 1867,"dev": 1073,"sources": ["nalibasid","tatoeba_challenge","xsid"],"by_source": {"nalibasid": 2722,"tatoeba_challenge": 216,"xsid": 2}},"baseline": {"records": 268537,"human_records": 40,53 unmodified lines"tatoeba_challenge": 506}},"baseline": {"records": 4786,"human_records": 124,52 unmodified lines"tatoeba_challenge": 143}},"baseline": {"records": 25457,"human_records": 3158,41 unmodified lines]},"evaluation": {"records": 0,"test": 0,"dev": 0,"sources": [],"by_source": {}},"baseline": {"records": 99399,"human_records": 1100,"human_share": 0.0111,"corpora": ["Tatoeba",5 unmodified lines"by_corpus_type": {"auto_mined": 65202,"entity_list": 33086,"crowd_sentences": 1100,"ui_strings": 11}}31 unmodified lines"tatoeba_challenge": 5368}},"baseline": {"records": 24065,"human_records": 18157,37 unmodified lines]},"evaluation": {"records": 79,"test": 79,"dev": 0,"sources": ["tatoeba_challenge"],"by_source": {"tatoeba_challenge": 79}},"baseline": {45 unmodified lines"tatoeba_challenge": 19292}},"baseline": {"records": 225567,"human_records": 30146,50 unmodified lines]},"evaluation": {"records": 0,"test": 0,"dev": 0,"sources": [],"by_source": {}},"baseline": {"records": 236037,"human_records": 1489,"human_share": 0.0063,"corpora": ["NLLB","QED",1 unmodified line"wikimedia"],"by_corpus_type": {"auto_mined": 233990,"subtitles": 1489,"ui_strings": 558}29 unmodified lines]},"evaluation": {"records": 0,"test": 0,"dev": 0,"sources": [],"by_source": {}},"baseline": {"records": 7706,39 unmodified lines"tatoeba_challenge": 80}},"baseline": {"records": 357,"human_records": 28,47 unmodified lines]},"evaluation": {"records": 0,"test": 0,"dev": 0,"sources": [],"by_source": {}},"baseline": {"records": 24777,12345678910111213141545 unmodified lines616263646566676869707172737475767778798048 unmodified lines12913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815944 unmodified lines2042052062072082092102112122132142152162172182192202212222232242252262272282292302312322 unmodified lines23523623723823924024142 unmodified lines28428528628728828929029129229329429529629729829930030145 unmodified lines3473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783791 unmodified line38138238338438538638738 unmodified lines42642742842943043143243343443543643743843944044144244344444544644744844945045145245345445542 unmodified lines49849950050150250350450550650750850951051151251351451546 unmodified lines56256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359 unmodified lines65365465565665765865966066166266366466566666766866967051 unmodified lines7227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517522 unmodified lines75575675775875976076130 unmodified lines79279379479579679779879980080180280380480580680780843 unmodified lines85285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488553 unmodified lines93994094194294394494594694794894995095195295395495552 unmodified lines100810091010101110121013101410151016101710181019102010211022102310241025102641 unmodified lines1068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610975 unmodified lines110311041105110611071108110931 unmodified lines11411142114311441145114611471148114911501151115211531154115511561157115837 unmodified lines11961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122245 unmodified lines126812691270127112721273127412751276127712781279128012811282128312841285128650 unmodified lines133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711 unmodified line137313741375137613771378137929 unmodified lines1409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143439 unmodified lines14741475147614771478147914801481148214831484148514861487148814891490149147 unmodified lines153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565{"description": "The languages this audit selected for low-resource translation work: a Wikipedia large enough to mine but not already saturated, at least one reachable human test set, and no Google or Microsoft Translator support. Ordered by opportunity_rank. Each entry also records the pivot languages chosen for it and how much evaluation and baseline data was actually found.","audit_release": "finewiki_audit_20261114T182048Z","evaluation_release": "eval_20261114T230126Z","baseline_release": "baseline_20261114T230143Z","evaluation_dataset": "sigiranic/underserved-translation-eval","baseline_dataset": "sigiranic/underserved-translation-baseline","lexicon_dataset": "sigiranic/underserved-translation-lexicons","lexicon_release": "lexicon_20261114T225919Z","count": 22,"with_evaluation_data": 22,"without_any_test_data": [],"pivot_rule": "The audit's shortlist languages and the pivot languages worth pairing each one with.","languages": [{45 unmodified lines"xsid": 1389}},"lexicon": {"entries": 10973,"redistributable_entries": 10973,"sources": ["chikhapo","divital"],"by_entry_type": {"word": 3327,"phrase": 1316,"example_sentence": 31,"token_gloss": 6299}},"baseline": {"records": 182,"human_records": 4,48 unmodified lines]},"evaluation": {"records": 436,"test": 436,"dev": 0,"sources": ["codet","tatoeba_challenge"],"by_source": {"codet": 380,"tatoeba_challenge": 56}},"lexicon": {"entries": 53113,"redistributable_entries": 1361,"sources": ["chikhapo","ladin_dizionar"],"by_entry_type": {"phrase": 40107,"word": 1278,"example_sentence": 11728}},"baseline": {"records": 4431,"human_records": 107,44 unmodified lines]},"evaluation": {"records": 3348,"test": 2102,"dev": 1246,"sources": ["bouquet"],"by_source": {"bouquet": 3348}},"lexicon": {"entries": 853,"redistributable_entries": 853,"sources": ["chikhapo"],"by_entry_type": {"word": 615,"phrase": 238}},"baseline": {"records": 10837,"human_records": 0,"human_share": 0.0,"corpora": [2 unmodified lines],"by_corpus_type": {"ui_strings": 7004,"auto_mined": 3833}}},42 unmodified lines"tatoeba_challenge": 39}},"lexicon": {"entries": 2059,"redistributable_entries": 2059,"sources": ["chikhapo"],"by_entry_type": {"word": 1373,"phrase": 685,"example_sentence": 1}},"baseline": {"records": 2894,"human_records": 0,45 unmodified lines]},"evaluation": {"records": 5861,"test": 3861,"dev": 2000,"sources": ["dolma_bitext","parme","smol"],"by_source": {"dolma_bitext": 998,"parme": 4000,"smol": 863}},"lexicon": {"entries": 3990,"redistributable_entries": 0,"sources": ["gilaki_top1000"],"by_entry_type": {"word": 1993,"example_sentence": 1997}},"baseline": {"records": 1677,"human_records": 0,"human_share": 0.0,"corpora": [1 unmodified line"wikimedia"],"by_corpus_type": {"ui_strings": 983,"auto_mined": 694}}38 unmodified lines]},"evaluation": {"records": 2162,"test": 2162,"dev": 0,"sources": ["codet","tatoeba_challenge"],"by_source": {"codet": 1408,"tatoeba_challenge": 754}},"lexicon": {"entries": 9486,"redistributable_entries": 9486,"sources": ["chikhapo"],"by_entry_type": {"phrase": 3282,"word": 6157,"example_sentence": 47}},"baseline": {"records": 23625,"human_records": 0,42 unmodified lines"tatoeba_challenge": 3388}},"lexicon": {"entries": 66051,"redistributable_entries": 66051,"sources": ["chikhapo"],"by_entry_type": {"word": 54574,"phrase": 11426,"example_sentence": 51}},"baseline": {"records": 7294,"human_records": 2217,46 unmodified lines]},"evaluation": {"records": 2509,"test": 2264,"dev": 245,"sources": ["codet","tatoeba_challenge","xsid"],"by_source": {"codet": 1814,"tatoeba_challenge": 2,"xsid": 693}},"lexicon": {"entries": 14020,"redistributable_entries": 14020,"sources": ["chikhapo"],"by_entry_type": {"word": 11844,"phrase": 2173,"example_sentence": 3}},"baseline": {"records": 11342,"human_records": 31,59 unmodified lines"parme": 4000}},"lexicon": {"entries": 1529,"redistributable_entries": 1529,"sources": ["chikhapo"],"by_entry_type": {"phrase": 617,"word": 910,"example_sentence": 2}},"baseline": {"records": 5654,"human_records": 0,51 unmodified lines]},"evaluation": {"records": 2583,"test": 2583,"dev": 0,"sources": ["codet","tatoeba_challenge"],"by_source": {"codet": 2188,"tatoeba_challenge": 395}},"lexicon": {"entries": 472,"redistributable_entries": 472,"sources": ["chikhapo"],"by_entry_type": {"word": 393,"phrase": 79}},"baseline": {"records": 966,"human_records": 0,"human_share": 0.0,"corpora": [2 unmodified lines],"by_corpus_type": {"auto_mined": 550,"ui_strings": 416}}},30 unmodified lines"tatoeba_challenge": 2077}},"lexicon": {"entries": 402,"redistributable_entries": 402,"sources": ["chikhapo"],"by_entry_type": {"word": 400,"phrase": 2}},"baseline": {"records": 2100,"human_records": 48,43 unmodified lines]},"evaluation": {"records": 2999,"test": 1926,"dev": 1073,"sources": ["maibaam","nalibasid","tatoeba_challenge","xsid"],"by_source": {"maibaam": 59,"nalibasid": 2722,"tatoeba_challenge": 216,"xsid": 2}},"lexicon": {"entries": 5345,"redistributable_entries": 5345,"sources": ["chikhapo"],"by_entry_type": {"word": 4896,"phrase": 440,"example_sentence": 9}},"baseline": {"records": 268537,"human_records": 40,53 unmodified lines"tatoeba_challenge": 506}},"lexicon": {"entries": 729,"redistributable_entries": 729,"sources": ["chikhapo"],"by_entry_type": {"word": 696,"phrase": 33}},"baseline": {"records": 4786,"human_records": 124,52 unmodified lines"tatoeba_challenge": 143}},"lexicon": {"entries": 13375,"redistributable_entries": 6234,"sources": ["apertium","chikhapo"],"by_entry_type": {"word": 12106,"example_sentence": 45,"phrase": 1224}},"baseline": {"records": 25457,"human_records": 3158,41 unmodified lines]},"evaluation": {"records": 3349,"test": 2103,"dev": 1246,"sources": ["bouquet"],"by_source": {"bouquet": 3349}},"lexicon": {"entries": 512,"redistributable_entries": 512,"sources": ["chikhapo"],"by_entry_type": {"word": 498,"phrase": 14}},"baseline": {"records": 99398,"human_records": 1099,"human_share": 0.0111,"corpora": ["Tatoeba",5 unmodified lines"by_corpus_type": {"auto_mined": 65202,"entity_list": 33086,"crowd_sentences": 1099,"ui_strings": 11}}31 unmodified lines"tatoeba_challenge": 5368}},"lexicon": {"entries": 28607,"redistributable_entries": 28607,"sources": ["chikhapo"],"by_entry_type": {"word": 26891,"phrase": 1715,"example_sentence": 1}},"baseline": {"records": 24065,"human_records": 18157,37 unmodified lines]},"evaluation": {"records": 228,"test": 228,"dev": 0,"sources": ["tatoeba_challenge","ud_megrelian"],"by_source": {"tatoeba_challenge": 79,"ud_megrelian": 149}},"lexicon": {"entries": 452,"redistributable_entries": 452,"sources": ["chikhapo"],"by_entry_type": {"phrase": 44,"word": 408}},"baseline": {45 unmodified lines"tatoeba_challenge": 19292}},"lexicon": {"entries": 50593,"redistributable_entries": 48144,"sources": ["apertium","chikhapo"],"by_entry_type": {"word": 44709,"example_sentence": 27,"phrase": 5857}},"baseline": {"records": 225567,"human_records": 30146,50 unmodified lines]},"evaluation": {"records": 7193,"test": 6993,"dev": 200,"sources": ["nllb_seed","nusax"],"by_source": {"nllb_seed": 6193,"nusax": 1000}},"lexicon": {"entries": 5445,"redistributable_entries": 5445,"sources": ["chikhapo","nusax_lexicon"],"by_entry_type": {"phrase": 594,"word": 4845,"example_sentence": 6}},"baseline": {"records": 227642,"human_records": 1489,"human_share": 0.0065,"corpora": ["NLLB","QED",1 unmodified line"wikimedia"],"by_corpus_type": {"auto_mined": 225595,"subtitles": 1489,"ui_strings": 558}29 unmodified lines]},"evaluation": {"records": 105,"test": 105,"dev": 0,"sources": ["glotstorybook"],"by_source": {"glotstorybook": 105}},"lexicon": {"entries": 226,"redistributable_entries": 226,"sources": ["chikhapo"],"by_entry_type": {"word": 225,"phrase": 1}},"baseline": {"records": 7706,39 unmodified lines"tatoeba_challenge": 80}},"lexicon": {"entries": 11871,"redistributable_entries": 11871,"sources": ["chikhapo"],"by_entry_type": {"word": 6514,"phrase": 5339,"example_sentence": 18}},"baseline": {"records": 357,"human_records": 28,47 unmodified lines]},"evaluation": {"records": 3348,"test": 2102,"dev": 1246,"sources": ["bouquet"],"by_source": {"bouquet": 3348}},"lexicon": {"entries": 4251,"redistributable_entries": 4251,"sources": ["chikhapo"],"by_entry_type": {"word": 2772,"phrase": 1460,"example_sentence": 19}},"baseline": {"records": 24777,
1 unmodified line23456789101112131415161718192021222324252627282930313233341 unmodified lineThe languages this audit selected for low-resource translation work: a Wikipedia large enough to mine but not already saturated, at least one reachable human test set, and no Google or Microsoft Translator support. Ordered by opportunity_rank. Each entry also records the pivot languages chosen for it and how much evaluation and baseline data was actually found.Audit release `finewiki_audit_20261114T182048Z`; 22 languages, 17 of them with evaluation data.| # | config | ISO | language | family | articles | pivots | eval | baseline | human baseline ||--:|---|---|---|---|--:|---|--:|--:|--:|| 1 | `als` | gsw | Alemannisch | Indo-European | 29,141 | `af`, `de`, `en`, `fr`, `lb` | 5,677 | 182 | 4 || 2 | `lld` | lld | Ladin | Indo-European | 180,820 | `ca`, `de`, `en`, `es`, `it`, `vec` | 56 | 4,431 | 107 || 4 | `azb` | azb | تۆرکجه | Turkic | 224,284 | `az`, `ba`, `en`, `kk`, `tr` | 0 | 9,835 | 0 || 5 | `bat_smg` | sgs | žemaitėška | Indo-European | 17,089 | `be`, `bg`, `en`, `lt`, `lv` | 39 | 2,894 | 0 || 7 | `glk` | glk | گیلکی | Indo-European | 47,607 | `ckb`, `en`, `fa`, `ku`, `mzn`, `tg` | 4,863 | 1,678 | 0 || 8 | `pms` | pms | Piemontèis | Indo-European | 69,013 | `ca`, `en`, `es`, `fr`, `ht`, `it`, `lmo` | 754 | 23,625 | 0 || 9 | `vo` | vol | Volapük | Artificial Language | 41,550 | `en`, `eo` | 3,388 | 7,294 | 2,217 || 11 | `nap` | nap | Napulitano | Indo-European | 14,753 | `ca`, `en`, `es`, `it`, `vec` | 695 | 11,342 | 31 || 13 | `mzn` | mzn | مازِرونی | Indo-European | 63,403 | `ckb`, `en`, `es`, `fa`, `ku`, `tg` | 4,000 | 5,654 | 0 || 16 | `eml` | egl | emiliàn e rumagnòl | Indo-European | 13,525 | `ca`, `en`, `fr`, `ht`, `it`, `lmo`, `oc`, `ur` | 395 | 967 | 0 || 17 | `avk` | avk | Kotava | Artificial Language | 26,979 | `en`, `eo` | 2,077 | 2,100 | 48 || 18 | `bar` | bar | Boarisch | Indo-European | 23,542 | `af`, `de`, `en`, `lb` | 2,940 | 268,537 | 40 || 19 | `frr` | frr | Nordfriisk | Indo-European | 18,723 | `af`, `de`, `en` | 506 | 4,786 | 124 || 20 | `sco` | sco | Scots | Indo-European | 32,294 | `af`, `de`, `en`, `it` | 143 | 25,457 | 3,158 || 21 | `wuu` | wuu | 吴语 | Sino-Tibetan | 45,237 | `en`, `zh`, `zh_yue` | 0 | 99,399 | 1,100 || 22 | `ie` | ile | Interlingue | Artificial Language | 13,311 | `en`, `eo` | 5,368 | 24,065 | 18,157 || 24 | `xmf` | xmf | მარგალური | Kartvelian | 21,832 | `en`, `ka` | 79 | 11,963 | 119 || 28 | `ia` | ina | interlingua | Artificial Language | 29,333 | `en`, `eo` | 19,292 | 225,567 | 30,146 || 47 | `bug` | bug | Basa Ugi | Austronesian | 15,954 | `ceb`, `en`, `id`, `jv`, `mg`, `ms` | 0 | 236,037 | 1,489 || 53 | `dag` | dag | dagbanli | Atlantic-Congo | 14,693 | `en`, `ig`, `sw`, `yo` | 0 | 7,706 | 0 || 58 | `nv` | nav | Diné bizaad | Athabaskan-Eyak-Tlingit | 22,538 | `en` | 80 | 357 | 28 || 73 | `skr` | skr | سرائیکی | Indo-European | 24,072 | `bn`, `en`, `hi`, `mr`, `pa`, `ur` | 0 | 24,777 | 84 |`azb`, `bug`, `dag`, `skr`, `wuu` passed every gate on catalogue evidence but no human-written test set could be retrieved for them, so they carry no evaluation records. They are kept in the list because that absence is the finding, not an error.`eval` and `baseline` are record counts in [sigiranic/underserved-translation-eval](https://huggingface.co/datasets/sigiranic/underserved-translation-eval) and [sigiranic/underserved-translation-baseline](https://huggingface.co/datasets/sigiranic/underserved-translation-baseline). `human baseline` is the part of the baseline written by people rather than mined or extracted automatically -- the number a mined corpus has to beat.1 unmodified line2345678910111213141516171819202122232425262728293031321 unmodified lineThe languages this audit selected for low-resource translation work: a Wikipedia large enough to mine but not already saturated, at least one reachable human test set, and no Google or Microsoft Translator support. Ordered by opportunity_rank. Each entry also records the pivot languages chosen for it and how much evaluation and baseline data was actually found.Audit release `finewiki_audit_20261114T182048Z`; 22 languages, 22 of them with evaluation data.| # | config | ISO | language | family | articles | pivots | eval | lexicon | baseline | human baseline ||--:|---|---|---|---|--:|---|--:|--:|--:|--:|| 1 | `als` | gsw | Alemannisch | Indo-European | 29,141 | `af`, `de`, `en`, `fr`, `lb` | 5,677 | 10,973 | 182 | 4 || 2 | `lld` | lld | Ladin | Indo-European | 180,820 | `ca`, `de`, `en`, `es`, `it`, `vec` | 436 | 53,113 | 4,431 | 107 || 4 | `azb` | azb | تۆرکجه | Turkic | 224,284 | `az`, `ba`, `en`, `kk`, `tr` | 3,348 | 853 | 10,837 | 0 || 5 | `bat_smg` | sgs | žemaitėška | Indo-European | 17,089 | `be`, `bg`, `en`, `lt`, `lv` | 39 | 2,059 | 2,894 | 0 || 7 | `glk` | glk | گیلکی | Indo-European | 47,607 | `ckb`, `en`, `fa`, `ku`, `mzn`, `tg` | 5,861 | 3,990 | 1,677 | 0 || 8 | `pms` | pms | Piemontèis | Indo-European | 69,013 | `ca`, `en`, `es`, `fr`, `ht`, `it`, `lmo` | 2,162 | 9,486 | 23,625 | 0 || 9 | `vo` | vol | Volapük | Artificial Language | 41,550 | `en`, `eo` | 3,388 | 66,051 | 7,294 | 2,217 || 11 | `nap` | nap | Napulitano | Indo-European | 14,753 | `ca`, `en`, `es`, `it`, `vec` | 2,509 | 14,020 | 11,342 | 31 || 13 | `mzn` | mzn | مازِرونی | Indo-European | 63,403 | `ckb`, `en`, `es`, `fa`, `ku`, `tg` | 4,000 | 1,529 | 5,654 | 0 || 16 | `eml` | egl | emiliàn e rumagnòl | Indo-European | 13,525 | `ca`, `en`, `fr`, `ht`, `it`, `lmo`, `oc`, `ur` | 2,583 | 472 | 966 | 0 || 17 | `avk` | avk | Kotava | Artificial Language | 26,979 | `en`, `eo` | 2,077 | 402 | 2,100 | 48 || 18 | `bar` | bar | Boarisch | Indo-European | 23,542 | `af`, `de`, `en`, `lb` | 2,999 | 5,345 | 268,537 | 40 || 19 | `frr` | frr | Nordfriisk | Indo-European | 18,723 | `af`, `de`, `en` | 506 | 729 | 4,786 | 124 || 20 | `sco` | sco | Scots | Indo-European | 32,294 | `af`, `de`, `en`, `it` | 143 | 13,375 | 25,457 | 3,158 || 21 | `wuu` | wuu | 吴语 | Sino-Tibetan | 45,237 | `en`, `zh`, `zh_yue` | 3,349 | 512 | 99,398 | 1,099 || 22 | `ie` | ile | Interlingue | Artificial Language | 13,311 | `en`, `eo` | 5,368 | 28,607 | 24,065 | 18,157 || 24 | `xmf` | xmf | მარგალური | Kartvelian | 21,832 | `en`, `ka` | 228 | 452 | 11,963 | 119 || 28 | `ia` | ina | interlingua | Artificial Language | 29,333 | `en`, `eo` | 19,292 | 50,593 | 225,567 | 30,146 || 47 | `bug` | bug | Basa Ugi | Austronesian | 15,954 | `ceb`, `en`, `id`, `jv`, `mg`, `ms` | 7,193 | 5,445 | 227,642 | 1,489 || 53 | `dag` | dag | dagbanli | Atlantic-Congo | 14,693 | `en`, `ig`, `sw`, `yo` | 105 | 226 | 7,706 | 0 || 58 | `nv` | nav | Diné bizaad | Athabaskan-Eyak-Tlingit | 22,538 | `en` | 80 | 11,871 | 357 | 28 || 73 | `skr` | skr | سرائیکی | Indo-European | 24,072 | `bn`, `en`, `hi`, `mr`, `pa`, `ur` | 3,348 | 4,251 | 24,777 | 84 |`eval`, `lexicon` and `baseline` are counts in [sigiranic/underserved-translation-eval](https://huggingface.co/datasets/sigiranic/underserved-translation-eval) and [sigiranic/underserved-translation-baseline](https://huggingface.co/datasets/sigiranic/underserved-translation-baseline). `human baseline` is the part of the baseline written by people rather than mined or extracted automatically -- the number a mined corpus has to beat.
172 unmodified lines173174175176177178179180228 unmodified lines409410411412413414415416417418419420421422423424425426427172 unmodified linesmade = evalc.collect_flores_reference(["wuu"], rows)self.assertEqual(len(made), 2) # dev and testfor record in made:self.assertIsNone(record["src"])self.assertIsNone(record["trg"])self.assertTrue(record["text_withheld"])self.assertIn("crawlers", record["withheld_reason"])228 unmodified linesfor line in handle:record = json.loads(line)if record.get("text_withheld"):self.assertNotIn("src", record)continueself.assertTrue(record["src"].strip())self.assertTrue(record["trg"].strip())def test_flores_text_is_never_published(self):for path in (self.eval_release / "languages").glob("*.jsonl"):with path.open(encoding="utf-8") as handle:for line in handle:record = json.loads(line)if record.get("source") == "flores_plus":self.assertNotIn("src", record)self.assertNotIn("trg", record)def test_ids_are_contiguous_within_each_language(self):for path in (self.eval_release / "languages").glob("*.jsonl"):172 unmodified lines173174175176177178179180181228 unmodified lines410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447172 unmodified linesmade = evalc.collect_flores_reference(["wuu"], rows)self.assertEqual(len(made), 2) # dev and testfor record in made:# Withheld rows carry empty text rather than null, uniformly across sources.self.assertEqual(record["src"], "")self.assertEqual(record["trg"], "")self.assertTrue(record["text_withheld"])self.assertIn("crawlers", record["withheld_reason"])228 unmodified linesfor line in handle:record = json.loads(line)if record.get("text_withheld"):self.assertEqual(record.get("src", ""), "")continueself.assertTrue(record["src"].strip())self.assertTrue(record["trg"].strip())def test_no_withheld_source_leaks_its_text(self):"""Generalised from the FLORES+ case: every tier-3 source must be textless.FLORES+ is no longer the only source we are not allowed to pass on, so checking itby name would let the next one through unnoticed."""withheld_sources = {name for name, meta in evalc.SOURCE_META.items()if meta["tier"] == evalc.TIER_REFERENCE}self.assertIn("flores_plus", withheld_sources)seen = set()for path in (self.eval_release / "languages").glob("*.jsonl"):with path.open(encoding="utf-8") as handle:for line in handle:record = json.loads(line)if record.get("source") not in withheld_sources:continueseen.add(record["source"])with self.subTest(source=record["source"], language=record["tl"]):self.assertEqual(record.get("src") or "", "")self.assertEqual(record.get("trg") or "", "")self.assertTrue(record["text_withheld"])self.assertFalse(record["redistributable"])# The row still has to say what it stands for.self.assertTrue(record.get("upstream_rows"))self.assertTrue(seen, "no withheld rows found in the release at all")def test_ids_are_contiguous_within_each_language(self):for path in (self.eval_release / "languages").glob("*.jsonl"):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205"""Tests for the lexicon corpus and for the licence tiering both corpora share."""
from __future__ import annotations
import jsonimport sysimport unittestfrom pathlib import Path
ROOT = Path(__file__).resolve().parents[1]sys.path.insert(0, str(ROOT / "scripts"))
import build_eval_corpus as evalc # noqa: E402import build_lexicon_corpus as lex # noqa: E402
class EntryTypes(unittest.TestCase): def test_a_single_token_is_a_word(self): self.assertEqual(lex._entry_type("Hoibe"), "word")
def test_a_short_multiword_gloss_is_a_phrase(self): self.assertEqual(lex._entry_type("ti dé de n pe"), "phrase")
def test_a_terminated_sentence_is_an_example(self): self.assertEqual(lex._entry_type("Mr. Mahmoud is a good person."), "example_sentence")
def test_a_long_run_without_punctuation_is_still_an_example(self): self.assertEqual( lex._entry_type("آقا محمود آدم خوبى است و همه او را دوست دارند"), "example_sentence", )
def test_persian_question_mark_terminates_a_sentence(self): self.assertEqual(lex._entry_type("چه خبر؟"), "example_sentence")
def test_empty_text_does_not_raise(self): self.assertEqual(lex._entry_type(""), "word") self.assertEqual(lex._entry_type(None), "word")
class ApertiumDictionaries(unittest.TestCase): DIX = b"""<?xml version="1.0" encoding="UTF-8"?> <dictionary> <section id="main" type="standard"> <e><p><l>house<s n="n"/></l><r>hoose<s n="n"/></r></p></e> <e><p><l>water</l><r>watter</r></p></e> <e><i>radio</i></e> <e><p><l>broken</l></p></e> </section> </dictionary>"""
def test_paired_entries_are_read(self): pairs = lex._dix_pairs(self.DIX, "eng", "sco") self.assertIn(("house", "hoose"), pairs) self.assertIn(("water", "watter"), pairs)
def test_a_shared_form_entry_becomes_an_identical_pair(self): self.assertIn(("radio", "radio"), lex._dix_pairs(self.DIX, "eng", "sco"))
def test_a_half_entry_is_skipped_rather_than_guessed(self): pairs = lex._dix_pairs(self.DIX, "eng", "sco") self.assertNotIn("broken", [left for left, _ in pairs]) self.assertEqual(len(pairs), 3)
def test_malformed_xml_yields_nothing_rather_than_raising(self): self.assertEqual(lex._dix_pairs(b"<dictionary><e>", "eng", "sco"), [])
class LicenceTiers(unittest.TestCase): def test_every_source_declares_a_tier(self): for name, meta in lex.SOURCE_META.items(): with self.subTest(source=name): self.assertIn(meta["tier"], (1, 2, 3)) self.assertTrue(meta["licence"])
def test_a_restricted_source_states_its_restriction(self): for name, meta in lex.SOURCE_META.items(): if meta["tier"] == lex.TIER_RESTRICTED: with self.subTest(source=name): self.assertTrue(meta["restriction"], f"{name} is restricted but says nothing about why")
def test_copyleft_sources_are_not_filed_as_freely_redistributable(self): for name, meta in lex.SOURCE_META.items(): if "GPL" in meta["licence"] or "-NC" in meta["licence"]: with self.subTest(source=name): self.assertNotEqual(meta["tier"], lex.TIER_REDISTRIBUTABLE)
def test_a_reference_only_entry_carries_no_text(self): lex.SOURCE_META["_probe"] = { "url": "x", "revision": "1", "licence": "none stated", "note": "", "tier": lex.TIER_REFERENCE, "restriction": "test", } try: entry = lex.make_entry(pivot_config="en", target_config="glk", src="secret", trg="secret", source="_probe", entry_type="word") finally: del lex.SOURCE_META["_probe"] self.assertEqual((entry["src"], entry["trg"]), ("", "")) self.assertTrue(entry["text_withheld"]) self.assertFalse(entry["redistributable"])
class LexiconDeduplication(unittest.TestCase): def _entry(self, source, tier, src="house", trg="hoose"): return {"tl": "sco", "sl": "en", "src": src, "trg": trg, "source": source, "licence_tier": tier}
def test_the_freest_copy_of_a_duplicate_wins(self): kept, dropped = lex.deduplicate([ self._entry("apertium", lex.TIER_RESTRICTED), self._entry("chikhapo", lex.TIER_REDISTRIBUTABLE), ]) self.assertEqual(len(kept), 1) self.assertEqual(kept[0]["source"], "chikhapo") self.assertEqual(len(dropped), 1)
def test_order_does_not_decide_the_winner(self): for order in ([lex.TIER_REDISTRIBUTABLE, lex.TIER_RESTRICTED], [lex.TIER_RESTRICTED, lex.TIER_REDISTRIBUTABLE]): kept, _ = lex.deduplicate([self._entry(f"s{t}", t) for t in order]) self.assertEqual(kept[0]["licence_tier"], lex.TIER_REDISTRIBUTABLE)
def test_different_pairs_are_both_kept(self): kept, _ = lex.deduplicate([ self._entry("chikhapo", 1, "house", "hoose"), self._entry("chikhapo", 1, "water", "watter"), ]) self.assertEqual(len(kept), 2)
class EvalLicenceTiers(unittest.TestCase): """The same tiering, in the evaluation corpus."""
def test_every_eval_source_declares_a_tier(self): for name, meta in evalc.SOURCE_META.items(): with self.subTest(source=name): self.assertIn(meta["tier"], (1, 2, 3))
def test_reference_only_sources_withhold_their_text(self): for name, meta in evalc.SOURCE_META.items(): if meta["tier"] != evalc.TIER_REFERENCE: continue with self.subTest(source=name): record = evalc.make_record( pivot_config="en", target_config="dag", src="secret", trg="secret", source=name, split="test", ) self.assertEqual((record["src"], record["trg"]), ("", "")) self.assertTrue(record["text_withheld"]) self.assertTrue(record["withheld_reason"])
def test_a_redistributable_source_keeps_its_text(self): record = evalc.make_record( pivot_config="en", target_config="bar", src="Hello", trg="Servus", source="maibaam", split="test", ) self.assertEqual(record["trg"], "Servus") self.assertTrue(record["redistributable"]) self.assertIsNone(record["licence_restriction"])
class ReleaseIntegrity(unittest.TestCase): @classmethod def setUpClass(cls): releases = sorted((ROOT / "dist" / "lexicon_corpus").glob("lexicon_*")) if not releases: raise unittest.SkipTest("no lexicon release built yet") cls.release = releases[-1] cls.manifest = json.loads( (cls.release / "manifest.json").read_text(encoding="utf-8") )
def test_every_shortlist_language_has_a_file(self): for config in self.manifest["languages"]: self.assertTrue((self.release / "languages" / f"{config}.jsonl").exists())
def test_subsets_partition_the_release(self): subsets = self.manifest["subsets"] total = subsets["all"]["records"] self.assertEqual(total, self.manifest["total_entries"]) self.assertEqual(sum(v["records"] for k, v in subsets.items() if k != "all"), total)
def test_tier_counts_sum_to_the_total(self): self.assertEqual(sum(self.manifest["entries_by_licence_tier"].values()), self.manifest["total_entries"])
def test_gilaki_has_entries_because_it_is_the_point_of_the_project(self): self.assertGreater(self.manifest["languages"]["glk"]["entries"], 0)
def test_the_language_set_matches_the_evaluation_corpus(self): eval_releases = sorted((ROOT / "dist" / "eval_corpus").glob("eval_*")) if not eval_releases: self.skipTest("no eval release built yet") eval_manifest = json.loads( (eval_releases[-1] / "manifest.json").read_text(encoding="utf-8") ) self.assertEqual(set(self.manifest["languages"]), set(eval_manifest["languages"]))
if __name__ == "__main__": unittest.main()README.md+4-1
manifest.json+26-21
scripts/build_eval_corpus.py+604-17
scripts/build_lexicon_corpus.pyAdded+713
scripts/publish_corpus.py+132-2
scripts/stage_audit_extras.py+22-4
selected_languages.json+356-62
selected_languages.md+26-28
tests/test_eval_corpus.py+27-7
tests/test_lexicon_corpus.pyAdded+205