Datasets:
Translation-resource audit of 325 FineWiki languages (finewiki_audit_20261114T182048Z)
Browse files- README.md +4 -1
- manifest.json +26 -21
- scripts/build_eval_corpus.py +604 -17
- scripts/build_lexicon_corpus.py +713 -0
- 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.py +205 -0
README.md
CHANGED
|
@@ -173,6 +173,7 @@ python scripts/lang_audit_build.py
|
|
| 173 |
python scripts/shortlist_pivots.py
|
| 174 |
python scripts/build_eval_corpus.py
|
| 175 |
python scripts/build_baseline_corpus.py
|
|
|
|
| 176 |
python scripts/stage_audit_extras.py
|
| 177 |
python scripts/publish_lang_audit.py
|
| 178 |
python scripts/publish_corpus.py
|
|
@@ -187,6 +188,7 @@ python scripts/publish_corpus.py
|
|
| 187 |
| `scripts/shortlist_pivots.py` | Derives the shortlist from the row state and chooses each language's pivots. |
|
| 188 |
| `scripts/build_eval_corpus.py` | Gathers the human-written test sets for the shortlist into the evaluation dataset. |
|
| 189 |
| `scripts/build_baseline_corpus.py` | Downloads the existing OPUS and Tatoeba training data as the comparison baseline. |
|
|
|
|
| 190 |
| `scripts/corpus_subsets.py` | Shared subset writer used by both corpus builders (<source>-<language> configs). |
|
| 191 |
| `scripts/stage_audit_extras.py` | Adds this script bundle and selected_languages.json to the staged audit release. |
|
| 192 |
| `scripts/publish_lang_audit.py` | Validates the staged release, uploads it and waits for the Dataset Viewer. |
|
|
@@ -194,7 +196,8 @@ python scripts/publish_corpus.py
|
|
| 194 |
| `scripts/hf_publishing_auth.py` | Reads the write token from the macOS Keychain; no credential is ever written to disk. |
|
| 195 |
| `configs/community_benchmarks.json` | Curated community test sets (PARME, xSID, NaLiBaSID) with pinned revisions. |
|
| 196 |
| `tests/test_lang_audit.py` | Tests for the audit: code resolution, prefix collisions, thresholds, derived columns. |
|
| 197 |
-
| `tests/test_eval_corpus.py` | Tests for
|
|
|
|
| 198 |
|
| 199 |
The tests run with `.venv-publish/bin/python -m unittest discover -s tests -q`.
|
| 200 |
|
|
|
|
| 173 |
python scripts/shortlist_pivots.py
|
| 174 |
python scripts/build_eval_corpus.py
|
| 175 |
python scripts/build_baseline_corpus.py
|
| 176 |
+
python scripts/build_lexicon_corpus.py
|
| 177 |
python scripts/stage_audit_extras.py
|
| 178 |
python scripts/publish_lang_audit.py
|
| 179 |
python scripts/publish_corpus.py
|
|
|
|
| 188 |
| `scripts/shortlist_pivots.py` | Derives the shortlist from the row state and chooses each language's pivots. |
|
| 189 |
| `scripts/build_eval_corpus.py` | Gathers the human-written test sets for the shortlist into the evaluation dataset. |
|
| 190 |
| `scripts/build_baseline_corpus.py` | Downloads the existing OPUS and Tatoeba training data as the comparison baseline. |
|
| 191 |
+
| `scripts/build_lexicon_corpus.py` | Gathers bilingual dictionaries, wordlists and token glosses into the lexicon dataset. |
|
| 192 |
| `scripts/corpus_subsets.py` | Shared subset writer used by both corpus builders (<source>-<language> configs). |
|
| 193 |
| `scripts/stage_audit_extras.py` | Adds this script bundle and selected_languages.json to the staged audit release. |
|
| 194 |
| `scripts/publish_lang_audit.py` | Validates the staged release, uploads it and waits for the Dataset Viewer. |
|
|
|
|
| 196 |
| `scripts/hf_publishing_auth.py` | Reads the write token from the macOS Keychain; no credential is ever written to disk. |
|
| 197 |
| `configs/community_benchmarks.json` | Curated community test sets (PARME, xSID, NaLiBaSID) with pinned revisions. |
|
| 198 |
| `tests/test_lang_audit.py` | Tests for the audit: code resolution, prefix collisions, thresholds, derived columns. |
|
| 199 |
+
| `tests/test_eval_corpus.py` | Tests for the sentence corpora: parsing, pivots, de-duplication, contamination. |
|
| 200 |
+
| `tests/test_lexicon_corpus.py` | Tests for the lexicon corpus and the licence tiering both corpora share. |
|
| 201 |
|
| 202 |
The tests run with `.venv-publish/bin/python -m unittest discover -s tests -q`.
|
| 203 |
|
manifest.json
CHANGED
|
@@ -904,23 +904,25 @@
|
|
| 904 |
"shortlist.json": "9eb370fd14a2913f17b480efac11289c9f44a8ee458a68428e96028c11525cc2",
|
| 905 |
"sources/finewiki_article_overlap.json": "2497aaf4a9a2f32ef716ccff8509f2e4c16808318429cf598bf29088ee070b82",
|
| 906 |
"sources/finewiki_article_coverage.json": "5c53008bf6e0d7b30b13890cea7ddca105b3f78cfb9699d9a945fbc0aab17573",
|
| 907 |
-
"selected_languages.json": "
|
| 908 |
-
"selected_languages.md": "
|
| 909 |
"scripts/lang_audit_sources.py": "e8074e36a09240d73c9891a7ee1f48b9483b45ee8c1816ca0d237abcd7e33ef3",
|
| 910 |
"scripts/lang_audit_overlap.py": "8c6ae3a88ef123a0d1a86c80d9b27394f5c7ffa6662398b291c96ad549e1b253",
|
| 911 |
"scripts/lang_audit_coverage.py": "4ae0d267ea3dde5e71ea6b02919d68081b77d5a327e8dbe74e9057f952447324",
|
| 912 |
"scripts/lang_audit_build.py": "0a61d4ff2fe59e3589054ed3548060df3880bcfc2736cd62b3d8089f8ffbe16f",
|
| 913 |
"scripts/shortlist_pivots.py": "2434fb92c24384bb34c84799ed53c02b059ccc1bcdadfe9fb0fed0fbbda0cae8",
|
| 914 |
-
"scripts/build_eval_corpus.py": "
|
| 915 |
"scripts/build_baseline_corpus.py": "7e96e4560bda0f5ffe7010b264d42db1b59f54cdf1e16ba6ce44267389bd9be6",
|
| 916 |
"scripts/corpus_subsets.py": "79cb36857537df1c911422abcd504e5ac3b10d3d69636dd6b576e2c88eb96b7c",
|
| 917 |
-
"scripts/stage_audit_extras.py": "
|
| 918 |
"scripts/publish_lang_audit.py": "937ce20efcae739401bf3432b59b15bbfc1346fce0660a6261a402c98e1d9064",
|
| 919 |
-
"scripts/publish_corpus.py": "
|
| 920 |
"scripts/hf_publishing_auth.py": "9f5d3fd2f78c9d47d2622bd0e05c944d1aca97115d3eb5bee7eff0bc20d04e95",
|
| 921 |
"configs/community_benchmarks.json": "54c99f1f8d91fc72d76dac819176ac380256449785518e1078b3b9fc63c11682",
|
| 922 |
"tests/test_lang_audit.py": "2d9e9a45f882a8c877f145dc94e02adc2925cfc34bb4860f6db501044e4ca724",
|
| 923 |
-
"tests/test_eval_corpus.py": "
|
|
|
|
|
|
|
| 924 |
},
|
| 925 |
"columns": [
|
| 926 |
"finewiki_config",
|
|
@@ -1040,6 +1042,7 @@
|
|
| 1040 |
"scripts/shortlist_pivots.py",
|
| 1041 |
"scripts/build_eval_corpus.py",
|
| 1042 |
"scripts/build_baseline_corpus.py",
|
|
|
|
| 1043 |
"scripts/corpus_subsets.py",
|
| 1044 |
"scripts/stage_audit_extras.py",
|
| 1045 |
"scripts/publish_lang_audit.py",
|
|
@@ -1069,19 +1072,23 @@
|
|
| 1069 |
},
|
| 1070 |
"scripts/build_eval_corpus.py": {
|
| 1071 |
"role": "Gathers the human-written test sets for the shortlist into the evaluation dataset.",
|
| 1072 |
-
"sha256": "
|
| 1073 |
},
|
| 1074 |
"scripts/build_baseline_corpus.py": {
|
| 1075 |
"role": "Downloads the existing OPUS and Tatoeba training data as the comparison baseline.",
|
| 1076 |
"sha256": "7e96e4560bda0f5ffe7010b264d42db1b59f54cdf1e16ba6ce44267389bd9be6"
|
| 1077 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1078 |
"scripts/corpus_subsets.py": {
|
| 1079 |
"role": "Shared subset writer used by both corpus builders (<source>-<language> configs).",
|
| 1080 |
"sha256": "79cb36857537df1c911422abcd504e5ac3b10d3d69636dd6b576e2c88eb96b7c"
|
| 1081 |
},
|
| 1082 |
"scripts/stage_audit_extras.py": {
|
| 1083 |
"role": "Adds this script bundle and selected_languages.json to the staged audit release.",
|
| 1084 |
-
"sha256": "
|
| 1085 |
},
|
| 1086 |
"scripts/publish_lang_audit.py": {
|
| 1087 |
"role": "Validates the staged release, uploads it and waits for the Dataset Viewer.",
|
|
@@ -1089,7 +1096,7 @@
|
|
| 1089 |
},
|
| 1090 |
"scripts/publish_corpus.py": {
|
| 1091 |
"role": "The same for the evaluation and baseline datasets.",
|
| 1092 |
-
"sha256": "
|
| 1093 |
},
|
| 1094 |
"scripts/hf_publishing_auth.py": {
|
| 1095 |
"role": "Reads the write token from the macOS Keychain; no credential is ever written to disk.",
|
|
@@ -1104,21 +1111,19 @@
|
|
| 1104 |
"sha256": "2d9e9a45f882a8c877f145dc94e02adc2925cfc34bb4860f6db501044e4ca724"
|
| 1105 |
},
|
| 1106 |
"tests/test_eval_corpus.py": {
|
| 1107 |
-
"role": "Tests for
|
| 1108 |
-
"sha256": "
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1109 |
}
|
| 1110 |
}
|
| 1111 |
},
|
| 1112 |
"selected_languages": {
|
| 1113 |
"count": 22,
|
| 1114 |
-
"with_evaluation_data":
|
| 1115 |
-
"without_any_test_data": [
|
| 1116 |
-
"azb",
|
| 1117 |
-
"bug",
|
| 1118 |
-
"dag",
|
| 1119 |
-
"skr",
|
| 1120 |
-
"wuu"
|
| 1121 |
-
],
|
| 1122 |
"configs": [
|
| 1123 |
"als",
|
| 1124 |
"lld",
|
|
@@ -1145,7 +1150,7 @@
|
|
| 1145 |
],
|
| 1146 |
"evaluation_dataset": "sigiranic/underserved-translation-eval",
|
| 1147 |
"baseline_dataset": "sigiranic/underserved-translation-baseline",
|
| 1148 |
-
"evaluation_release": "
|
| 1149 |
-
"baseline_release": "
|
| 1150 |
}
|
| 1151 |
}
|
|
|
|
| 904 |
"shortlist.json": "9eb370fd14a2913f17b480efac11289c9f44a8ee458a68428e96028c11525cc2",
|
| 905 |
"sources/finewiki_article_overlap.json": "2497aaf4a9a2f32ef716ccff8509f2e4c16808318429cf598bf29088ee070b82",
|
| 906 |
"sources/finewiki_article_coverage.json": "5c53008bf6e0d7b30b13890cea7ddca105b3f78cfb9699d9a945fbc0aab17573",
|
| 907 |
+
"selected_languages.json": "8fb8b11e0002749c3084690eb0a262accaa5afecdaa5eec4b17142b508061328",
|
| 908 |
+
"selected_languages.md": "776167cb7846236f66ae7b226dc9f6b88ec332995594a0d52caa304513b0d97b",
|
| 909 |
"scripts/lang_audit_sources.py": "e8074e36a09240d73c9891a7ee1f48b9483b45ee8c1816ca0d237abcd7e33ef3",
|
| 910 |
"scripts/lang_audit_overlap.py": "8c6ae3a88ef123a0d1a86c80d9b27394f5c7ffa6662398b291c96ad549e1b253",
|
| 911 |
"scripts/lang_audit_coverage.py": "4ae0d267ea3dde5e71ea6b02919d68081b77d5a327e8dbe74e9057f952447324",
|
| 912 |
"scripts/lang_audit_build.py": "0a61d4ff2fe59e3589054ed3548060df3880bcfc2736cd62b3d8089f8ffbe16f",
|
| 913 |
"scripts/shortlist_pivots.py": "2434fb92c24384bb34c84799ed53c02b059ccc1bcdadfe9fb0fed0fbbda0cae8",
|
| 914 |
+
"scripts/build_eval_corpus.py": "b350af213274c84e9b9d67c05e43d9339a5ffb9438e70038f40982145ae5e4cc",
|
| 915 |
"scripts/build_baseline_corpus.py": "7e96e4560bda0f5ffe7010b264d42db1b59f54cdf1e16ba6ce44267389bd9be6",
|
| 916 |
"scripts/corpus_subsets.py": "79cb36857537df1c911422abcd504e5ac3b10d3d69636dd6b576e2c88eb96b7c",
|
| 917 |
+
"scripts/stage_audit_extras.py": "a2e48f3c1ee371085835827b624ae7c9653880143d18ec1d154dc958a7993fbb",
|
| 918 |
"scripts/publish_lang_audit.py": "937ce20efcae739401bf3432b59b15bbfc1346fce0660a6261a402c98e1d9064",
|
| 919 |
+
"scripts/publish_corpus.py": "991a4b368867de7de825ead7be8d95b225c6fb0c4731af04f3b94d82aaa6dac2",
|
| 920 |
"scripts/hf_publishing_auth.py": "9f5d3fd2f78c9d47d2622bd0e05c944d1aca97115d3eb5bee7eff0bc20d04e95",
|
| 921 |
"configs/community_benchmarks.json": "54c99f1f8d91fc72d76dac819176ac380256449785518e1078b3b9fc63c11682",
|
| 922 |
"tests/test_lang_audit.py": "2d9e9a45f882a8c877f145dc94e02adc2925cfc34bb4860f6db501044e4ca724",
|
| 923 |
+
"tests/test_eval_corpus.py": "40314dea957b2ca752ae89f3fd6ea0e172438d00365f190bd81f66995dd1fc16",
|
| 924 |
+
"scripts/build_lexicon_corpus.py": "4365141aab4f1633e6401b453910d7600949db8d033da40d309b3ea52ee861a5",
|
| 925 |
+
"tests/test_lexicon_corpus.py": "c2b4ffdcbc913d314c334db50c9d1b255918f70ac75ec5df143253901dab0a92"
|
| 926 |
},
|
| 927 |
"columns": [
|
| 928 |
"finewiki_config",
|
|
|
|
| 1042 |
"scripts/shortlist_pivots.py",
|
| 1043 |
"scripts/build_eval_corpus.py",
|
| 1044 |
"scripts/build_baseline_corpus.py",
|
| 1045 |
+
"scripts/build_lexicon_corpus.py",
|
| 1046 |
"scripts/corpus_subsets.py",
|
| 1047 |
"scripts/stage_audit_extras.py",
|
| 1048 |
"scripts/publish_lang_audit.py",
|
|
|
|
| 1072 |
},
|
| 1073 |
"scripts/build_eval_corpus.py": {
|
| 1074 |
"role": "Gathers the human-written test sets for the shortlist into the evaluation dataset.",
|
| 1075 |
+
"sha256": "b350af213274c84e9b9d67c05e43d9339a5ffb9438e70038f40982145ae5e4cc"
|
| 1076 |
},
|
| 1077 |
"scripts/build_baseline_corpus.py": {
|
| 1078 |
"role": "Downloads the existing OPUS and Tatoeba training data as the comparison baseline.",
|
| 1079 |
"sha256": "7e96e4560bda0f5ffe7010b264d42db1b59f54cdf1e16ba6ce44267389bd9be6"
|
| 1080 |
},
|
| 1081 |
+
"scripts/build_lexicon_corpus.py": {
|
| 1082 |
+
"role": "Gathers bilingual dictionaries, wordlists and token glosses into the lexicon dataset.",
|
| 1083 |
+
"sha256": "4365141aab4f1633e6401b453910d7600949db8d033da40d309b3ea52ee861a5"
|
| 1084 |
+
},
|
| 1085 |
"scripts/corpus_subsets.py": {
|
| 1086 |
"role": "Shared subset writer used by both corpus builders (<source>-<language> configs).",
|
| 1087 |
"sha256": "79cb36857537df1c911422abcd504e5ac3b10d3d69636dd6b576e2c88eb96b7c"
|
| 1088 |
},
|
| 1089 |
"scripts/stage_audit_extras.py": {
|
| 1090 |
"role": "Adds this script bundle and selected_languages.json to the staged audit release.",
|
| 1091 |
+
"sha256": "a2e48f3c1ee371085835827b624ae7c9653880143d18ec1d154dc958a7993fbb"
|
| 1092 |
},
|
| 1093 |
"scripts/publish_lang_audit.py": {
|
| 1094 |
"role": "Validates the staged release, uploads it and waits for the Dataset Viewer.",
|
|
|
|
| 1096 |
},
|
| 1097 |
"scripts/publish_corpus.py": {
|
| 1098 |
"role": "The same for the evaluation and baseline datasets.",
|
| 1099 |
+
"sha256": "991a4b368867de7de825ead7be8d95b225c6fb0c4731af04f3b94d82aaa6dac2"
|
| 1100 |
},
|
| 1101 |
"scripts/hf_publishing_auth.py": {
|
| 1102 |
"role": "Reads the write token from the macOS Keychain; no credential is ever written to disk.",
|
|
|
|
| 1111 |
"sha256": "2d9e9a45f882a8c877f145dc94e02adc2925cfc34bb4860f6db501044e4ca724"
|
| 1112 |
},
|
| 1113 |
"tests/test_eval_corpus.py": {
|
| 1114 |
+
"role": "Tests for the sentence corpora: parsing, pivots, de-duplication, contamination.",
|
| 1115 |
+
"sha256": "40314dea957b2ca752ae89f3fd6ea0e172438d00365f190bd81f66995dd1fc16"
|
| 1116 |
+
},
|
| 1117 |
+
"tests/test_lexicon_corpus.py": {
|
| 1118 |
+
"role": "Tests for the lexicon corpus and the licence tiering both corpora share.",
|
| 1119 |
+
"sha256": "c2b4ffdcbc913d314c334db50c9d1b255918f70ac75ec5df143253901dab0a92"
|
| 1120 |
}
|
| 1121 |
}
|
| 1122 |
},
|
| 1123 |
"selected_languages": {
|
| 1124 |
"count": 22,
|
| 1125 |
+
"with_evaluation_data": 22,
|
| 1126 |
+
"without_any_test_data": [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1127 |
"configs": [
|
| 1128 |
"als",
|
| 1129 |
"lld",
|
|
|
|
| 1150 |
],
|
| 1151 |
"evaluation_dataset": "sigiranic/underserved-translation-eval",
|
| 1152 |
"baseline_dataset": "sigiranic/underserved-translation-baseline",
|
| 1153 |
+
"evaluation_release": "eval_20261114T230126Z",
|
| 1154 |
+
"baseline_release": "baseline_20261114T230143Z"
|
| 1155 |
}
|
| 1156 |
}
|
scripts/build_eval_corpus.py
CHANGED
|
@@ -61,6 +61,22 @@ XSID_REVISION = "761d926c3f2e9f6bea13192d2f39cec1d04d9777"
|
|
| 61 |
NALIBASID_REVISION = "8d66b9021c06df1ab459636a925e119b2cff20fe"
|
| 62 |
NTREX_REVISION = "468c6b69c7f6a75d31d4743d9daba2af566cc18d"
|
| 63 |
PARME_REVISION = "6df9269acc75377ed6be3bf2f7966c8e238a62bd"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
SOURCE_META = {
|
| 66 |
"tatoeba_challenge": {
|
|
@@ -108,9 +124,111 @@ SOURCE_META = {
|
|
| 108 |
"note": "Text withheld. Access requires agreeing not to re-host FLORES+ where web "
|
| 109 |
"crawlers could reach it, which a public dataset repository would do. Fetch "
|
| 110 |
"it from the upstream repository after accepting its terms.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
},
|
| 112 |
}
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
# xSID ships automatically word-aligned projections next to the human translations; they are
|
| 115 |
# training material and must never enter a test set.
|
| 116 |
XSID_EXCLUDED = ("projectedTrain",)
|
|
@@ -259,9 +377,17 @@ def make_record(*, pivot_config, target_config, src, trg, source, split,
|
|
| 259 |
"source_revision": meta["revision"],
|
| 260 |
"licence": meta["licence"],
|
| 261 |
"domain": meta["domain"],
|
|
|
|
|
|
|
|
|
|
| 262 |
})
|
| 263 |
if extra:
|
| 264 |
record.update(extra)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
return record
|
| 266 |
|
| 267 |
|
|
@@ -474,30 +600,466 @@ def collect_smol(targets, rows):
|
|
| 474 |
|
| 475 |
def collect_flores_reference(targets, rows):
|
| 476 |
"""Reference-only rows for languages whose test set is the non-redistributable FLORES+."""
|
| 477 |
-
meta = SOURCE_META["flores_plus"]
|
| 478 |
out = []
|
| 479 |
for config in targets:
|
| 480 |
if not rows[config]["in_flores_plus"]:
|
| 481 |
continue
|
| 482 |
iso = rows[config]["iso639_3"]
|
| 483 |
for split, count in (("dev", 997), ("test", 1012)):
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
"
|
| 489 |
-
"
|
| 490 |
-
"
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
})
|
| 495 |
return out
|
| 496 |
|
| 497 |
|
| 498 |
# ------------------------------------------------------------------------------- assembly
|
| 499 |
|
| 500 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 501 |
def deduplicate(records, rows):
|
| 502 |
"""Collapse records that carry the same pair, keeping the most authoritative source.
|
| 503 |
|
|
@@ -506,12 +1068,20 @@ def deduplicate(records, rows):
|
|
| 506 |
order follows which release supersedes which, mirroring the ``supersedes`` declarations
|
| 507 |
in ``configs/community_benchmarks.json``.
|
| 508 |
"""
|
| 509 |
-
|
| 510 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
best: dict[tuple, dict] = {}
|
| 512 |
dropped = []
|
| 513 |
for record in records:
|
| 514 |
-
if record.get("
|
|
|
|
|
|
|
| 515 |
best[("ref", record["tl"], record["source"], record["split"])] = record
|
| 516 |
continue
|
| 517 |
key = (record["tl"], record["sl"], norm_key(record["src"]), norm_key(record["trg"]))
|
|
@@ -544,7 +1114,9 @@ def write_release(records, skipped, dropped, selection, rows, release_id=None):
|
|
| 544 |
columns = ["sl", "tl", "id", "src", "trg", "is_src_orig", "split", "source",
|
| 545 |
"source_url", "source_revision", "licence", "domain", "source_pair",
|
| 546 |
"source_variant", "intent", "variety", "released_as", "upstream_id",
|
| 547 |
-
"text_withheld", "withheld_reason", "upstream_rows", "upstream_file"
|
|
|
|
|
|
|
| 548 |
schema = pa.schema([
|
| 549 |
("sl", pa.string()), ("tl", pa.string()), ("id", pa.int64()),
|
| 550 |
("src", pa.string()), ("trg", pa.string()), ("is_src_orig", pa.bool_()),
|
|
@@ -555,6 +1127,11 @@ def write_release(records, skipped, dropped, selection, rows, release_id=None):
|
|
| 555 |
("upstream_id", pa.int64()), ("text_withheld", pa.bool_()),
|
| 556 |
("withheld_reason", pa.string()), ("upstream_rows", pa.int64()),
|
| 557 |
("upstream_file", pa.string()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 558 |
])
|
| 559 |
|
| 560 |
summary, flat = {}, []
|
|
@@ -673,11 +1250,21 @@ def build(release_id=None):
|
|
| 673 |
("nalibasid", lambda: collect_nalibasid(rows)),
|
| 674 |
("parme", lambda: collect_parme(rows)),
|
| 675 |
("smol", lambda: collect_smol(targets, rows)),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 676 |
):
|
| 677 |
got, missed = collector()
|
| 678 |
print(f" {label:<20} {len(got):>7,} records, {len(missed)} skipped", flush=True)
|
| 679 |
records += got
|
| 680 |
-
|
|
|
|
| 681 |
|
| 682 |
references = collect_flores_reference(targets, rows)
|
| 683 |
print(f" {'flores_plus (ref)':<20} {len(references):>7,} reference rows", flush=True)
|
|
|
|
| 61 |
NALIBASID_REVISION = "8d66b9021c06df1ab459636a925e119b2cff20fe"
|
| 62 |
NTREX_REVISION = "468c6b69c7f6a75d31d4743d9daba2af566cc18d"
|
| 63 |
PARME_REVISION = "6df9269acc75377ed6be3bf2f7966c8e238a62bd"
|
| 64 |
+
CODET_REVISION = "main"
|
| 65 |
+
DOLMA_BITEXT_REVISION = "main"
|
| 66 |
+
MAIBAAM_REVISION = "master"
|
| 67 |
+
UD_MEGRELIAN_REVISION = "dev"
|
| 68 |
+
NUSAX_REVISION = "main"
|
| 69 |
+
|
| 70 |
+
# How freely a source may be passed on. The distinction is not cosmetic: a third of the
|
| 71 |
+
# resources found for these languages carry no licence at all, and several of the best ones
|
| 72 |
+
# are explicitly non-commercial or no-derivatives. Publishing them all under one licence
|
| 73 |
+
# field would misrepresent every tier but the first.
|
| 74 |
+
#
|
| 75 |
+
# 1 redistributable: a licence that permits republishing the text.
|
| 76 |
+
# 2 restricted: republishable only under a condition that limits reuse (non-commercial).
|
| 77 |
+
# 3 reference only: no licence stated, no-derivatives, or an explicit request not to
|
| 78 |
+
# redistribute. Ids and counts are published; the text is withheld.
|
| 79 |
+
TIER_REDISTRIBUTABLE, TIER_RESTRICTED, TIER_REFERENCE = 1, 2, 3
|
| 80 |
|
| 81 |
SOURCE_META = {
|
| 82 |
"tatoeba_challenge": {
|
|
|
|
| 124 |
"note": "Text withheld. Access requires agreeing not to re-host FLORES+ where web "
|
| 125 |
"crawlers could reach it, which a public dataset repository would do. Fetch "
|
| 126 |
"it from the upstream repository after accepting its terms.",
|
| 127 |
+
"tier": TIER_REFERENCE,
|
| 128 |
+
"restriction": "Terms forbid re-hosting where web crawlers could reach it.",
|
| 129 |
+
},
|
| 130 |
+
"bouquet": {
|
| 131 |
+
"url": "https://huggingface.co/datasets/facebook/bouquet",
|
| 132 |
+
"revision": "main", "licence": "CC-BY-4.0", "domain": "mixed",
|
| 133 |
+
"note": "Human-authored sentences and paragraphs, written in the source language "
|
| 134 |
+
"rather than translated from English, with official dev and test splits. "
|
| 135 |
+
"Carries paragraph ids, so it is the only source here with recoverable "
|
| 136 |
+
"document structure. Released for evaluation, not training.",
|
| 137 |
+
"tier": TIER_REDISTRIBUTABLE,
|
| 138 |
+
},
|
| 139 |
+
"codet": {
|
| 140 |
+
"url": "https://github.com/mahfuzibnalam/dialect_mt",
|
| 141 |
+
"revision": CODET_REVISION, "licence": "MIT", "domain": "elicited_syntax",
|
| 142 |
+
"note": "Italian Syntactic Atlas sentences elicited from speakers in 439 localities, "
|
| 143 |
+
"each file positionally aligned to the same 792 standard Italian sentences. "
|
| 144 |
+
"Sparsely filled, so a locality contributes only the lines it answered.",
|
| 145 |
+
"tier": TIER_REDISTRIBUTABLE,
|
| 146 |
+
},
|
| 147 |
+
"dolma_bitext": {
|
| 148 |
+
"url": "https://github.com/DOLMA-NLP/bitext-mining",
|
| 149 |
+
"revision": DOLMA_BITEXT_REVISION, "licence": "CC-BY-4.0", "domain": "mixed",
|
| 150 |
+
"note": "Manually aligned sentence pairs from published translations, by the group "
|
| 151 |
+
"behind PARME. The licence adds one term: the data must not be used to "
|
| 152 |
+
"reconstruct the original literary works, which sentence-level use satisfies.",
|
| 153 |
+
"tier": TIER_REDISTRIBUTABLE,
|
| 154 |
+
},
|
| 155 |
+
"nllb_seed": {
|
| 156 |
+
"url": "https://github.com/facebookresearch/flores/tree/main/nllb_seed",
|
| 157 |
+
"revision": "main", "licence": "CC-BY-SA-4.0", "domain": "wiki_general",
|
| 158 |
+
"note": "Professionally translated seed sentences. A separate artefact from the "
|
| 159 |
+
"NLLB-200 mined bitext that the baseline corpus classifies as auto_mined.",
|
| 160 |
+
"tier": TIER_REDISTRIBUTABLE,
|
| 161 |
+
},
|
| 162 |
+
"nusax": {
|
| 163 |
+
"url": "https://github.com/IndoNLP/nusax",
|
| 164 |
+
"revision": NUSAX_REVISION, "licence": "CC-BY-SA-4.0", "domain": "mixed",
|
| 165 |
+
"note": "Twelve-way parallel sentences for Indonesian local languages, translated by "
|
| 166 |
+
"native speakers, with official train/valid/test splits.",
|
| 167 |
+
"tier": TIER_REDISTRIBUTABLE,
|
| 168 |
+
},
|
| 169 |
+
"maibaam": {
|
| 170 |
+
"url": "https://github.com/UniversalDependencies/UD_Bavarian-MaiBaam",
|
| 171 |
+
"revision": MAIBAAM_REVISION, "licence": "CC-BY-SA-4.0", "domain": "wiki_general",
|
| 172 |
+
"note": "English sentence translations carried as '# text_en' comments on part of "
|
| 173 |
+
"the Bavarian treebank. Only 59 of 1,070 sentences have one.",
|
| 174 |
+
"tier": TIER_REDISTRIBUTABLE,
|
| 175 |
+
},
|
| 176 |
+
"ud_megrelian": {
|
| 177 |
+
"url": "https://github.com/UniversalDependencies/UD_Megrelian-MLC",
|
| 178 |
+
"revision": UD_MEGRELIAN_REVISION, "licence": "CC-BY-SA-4.0", "domain": "mixed",
|
| 179 |
+
"note": "English translations carried as '# text_en' on the Megrelian treebank. Only "
|
| 180 |
+
"on the dev branch; the dependency columns are empty for every token, so it "
|
| 181 |
+
"is a translated morphology set rather than a usable treebank.",
|
| 182 |
+
"tier": TIER_REDISTRIBUTABLE,
|
| 183 |
+
},
|
| 184 |
+
"nsanku": {
|
| 185 |
+
"url": "https://github.com/GhanaNLP/nsanku",
|
| 186 |
+
"revision": "main", "licence": "none stated", "domain": "religious",
|
| 187 |
+
"note": "Human Dagbani-English reference pairs used as the evaluation set of Ghana "
|
| 188 |
+
"NLP's 43-language study. Text withheld: the repository ships no licence and "
|
| 189 |
+
"the underlying Bible translation is a Bible society copyright.",
|
| 190 |
+
"tier": TIER_REFERENCE,
|
| 191 |
+
"restriction": "No licence file in the repository; underlying text is copyrighted.",
|
| 192 |
+
},
|
| 193 |
+
"betthupferl": {
|
| 194 |
+
"url": "https://github.com/mainlp/betthupferl",
|
| 195 |
+
"revision": "main", "licence": "none stated", "domain": "narrative",
|
| 196 |
+
"note": "Human-transcribed and human-standardised Bavarian, Swabian and East "
|
| 197 |
+
"Franconian against Standard German. Text withheld: the archives are "
|
| 198 |
+
"password-protected and the authors ask that the data not be redistributed.",
|
| 199 |
+
"tier": TIER_REFERENCE,
|
| 200 |
+
"restriction": "Authors explicitly request no redistribution.",
|
| 201 |
+
},
|
| 202 |
+
"ladin_frontull": {
|
| 203 |
+
"url": "https://huggingface.co/sfrontull",
|
| 204 |
+
"revision": "main", "licence": "CC-BY-NC-SA-4.0", "domain": "mixed",
|
| 205 |
+
"note": "Italian-Ladin and intra-Ladin corpora. Non-commercial, so usable for "
|
| 206 |
+
"evaluation but not in a commercial system.",
|
| 207 |
+
"tier": TIER_RESTRICTED,
|
| 208 |
+
"restriction": "Non-commercial use only.",
|
| 209 |
+
},
|
| 210 |
+
"glotstorybook": {
|
| 211 |
+
"url": "https://huggingface.co/datasets/cis-lmu/GlotStoryBook",
|
| 212 |
+
"revision": "main", "licence": "CC-BY", "domain": "narrative",
|
| 213 |
+
"note": "African Storybook texts translated by named community translators, aligned "
|
| 214 |
+
"to English through each story's parallel id. Licensing is per row, so only "
|
| 215 |
+
"the plain CC-BY stories are taken.",
|
| 216 |
+
"tier": TIER_REDISTRIBUTABLE,
|
| 217 |
+
},
|
| 218 |
+
"ladin_weather": {
|
| 219 |
+
"url": "https://huggingface.co/datasets/sfrontull/south-tyrol-weather-lld-deu",
|
| 220 |
+
"revision": "main", "licence": "CC-BY-SA-4.0", "domain": "weather",
|
| 221 |
+
"note": "South Tyrol meteorological office bulletins in Ladin and German, with an "
|
| 222 |
+
"official test split. The only Ladin set paired with German rather than "
|
| 223 |
+
"Italian.",
|
| 224 |
+
"tier": TIER_REDISTRIBUTABLE,
|
| 225 |
},
|
| 226 |
}
|
| 227 |
|
| 228 |
+
for _name, _meta in SOURCE_META.items():
|
| 229 |
+
_meta.setdefault("tier", TIER_REDISTRIBUTABLE)
|
| 230 |
+
_meta.setdefault("restriction", None)
|
| 231 |
+
|
| 232 |
# xSID ships automatically word-aligned projections next to the human translations; they are
|
| 233 |
# training material and must never enter a test set.
|
| 234 |
XSID_EXCLUDED = ("projectedTrain",)
|
|
|
|
| 377 |
"source_revision": meta["revision"],
|
| 378 |
"licence": meta["licence"],
|
| 379 |
"domain": meta["domain"],
|
| 380 |
+
"licence_tier": meta["tier"],
|
| 381 |
+
"redistributable": meta["tier"] != TIER_REFERENCE,
|
| 382 |
+
"licence_restriction": meta["restriction"],
|
| 383 |
})
|
| 384 |
if extra:
|
| 385 |
record.update(extra)
|
| 386 |
+
if meta["tier"] == TIER_REFERENCE:
|
| 387 |
+
# Counted and attributable, but the text itself is not ours to pass on.
|
| 388 |
+
record["src"], record["trg"] = "", ""
|
| 389 |
+
record["text_withheld"] = True
|
| 390 |
+
record["withheld_reason"] = meta["restriction"] or "no licence stated"
|
| 391 |
return record
|
| 392 |
|
| 393 |
|
|
|
|
| 600 |
|
| 601 |
def collect_flores_reference(targets, rows):
|
| 602 |
"""Reference-only rows for languages whose test set is the non-redistributable FLORES+."""
|
|
|
|
| 603 |
out = []
|
| 604 |
for config in targets:
|
| 605 |
if not rows[config]["in_flores_plus"]:
|
| 606 |
continue
|
| 607 |
iso = rows[config]["iso639_3"]
|
| 608 |
for split, count in (("dev", 997), ("test", 1012)):
|
| 609 |
+
# Built through make_record like every other source, so that withheld rows carry
|
| 610 |
+
# the same tier fields and the same empty-string convention as the others rather
|
| 611 |
+
# than a second, nearly-identical shape.
|
| 612 |
+
out.append(make_record(
|
| 613 |
+
pivot_config="en", target_config=config, src="", trg="",
|
| 614 |
+
source="flores_plus", split=split,
|
| 615 |
+
extra={"upstream_rows": count,
|
| 616 |
+
"upstream_file":
|
| 617 |
+
f"{'dev' if split == 'dev' else 'devtest'}/{iso}_*.jsonl"},
|
| 618 |
+
))
|
|
|
|
| 619 |
return out
|
| 620 |
|
| 621 |
|
| 622 |
# ------------------------------------------------------------------------------- assembly
|
| 623 |
|
| 624 |
|
| 625 |
+
# BOUQuET codes its languages with a script tag; these are the ones that matter here, both
|
| 626 |
+
# for our targets and for the pivots they are paired with.
|
| 627 |
+
BOUQUET_TARGETS = {"azb": "azb_Arab", "skr": "skr_Arab", "wuu": "wuu_Hans"}
|
| 628 |
+
BOUQUET_PIVOTS = {"eng_Latn": "en", "pes_Arab": "fa", "hin_Deva": "hi", "cmn_Hans": "zh"}
|
| 629 |
+
|
| 630 |
+
|
| 631 |
+
def collect_bouquet(targets, rows):
|
| 632 |
+
"""BOUQuET dev and test, at sentence and paragraph level.
|
| 633 |
+
|
| 634 |
+
The only source here that is not translated out of English: every passage was written in
|
| 635 |
+
one of the languages and then translated outwards. It also carries ``par_id``, so a
|
| 636 |
+
sentence can be traced back to the paragraph it came from -- the one piece of document
|
| 637 |
+
structure in the whole collection.
|
| 638 |
+
"""
|
| 639 |
+
import pyarrow.parquet as pq
|
| 640 |
+
from huggingface_hub import hf_hub_download
|
| 641 |
+
from hf_publishing_auth import publishing_token
|
| 642 |
+
|
| 643 |
+
out, skipped = [], []
|
| 644 |
+
token = publishing_token()
|
| 645 |
+
for config, tagged in BOUQUET_TARGETS.items():
|
| 646 |
+
if config not in targets:
|
| 647 |
+
continue
|
| 648 |
+
for pivot_tag, pivot_config in BOUQUET_PIVOTS.items():
|
| 649 |
+
ok, _why = pivots.acceptable_pivot(config, pivot_config, rows)
|
| 650 |
+
if not ok:
|
| 651 |
+
skipped.append({"target": config, "pair": f"{pivot_tag}-{tagged}",
|
| 652 |
+
"reason": "pivot not acceptable", "source": "bouquet"})
|
| 653 |
+
continue
|
| 654 |
+
for level in ("sentence_level", "paragraph_level"):
|
| 655 |
+
for upstream, split in (("dev", "dev"), ("test", "test")):
|
| 656 |
+
name = (f"benchmark_data/{level}/{upstream}/{pivot_tag}-{tagged}.parquet")
|
| 657 |
+
try:
|
| 658 |
+
path = hf_hub_download("facebook/bouquet", name,
|
| 659 |
+
repo_type="dataset", token=token)
|
| 660 |
+
except Exception as error: # noqa: BLE001 - absent pair or no access
|
| 661 |
+
skipped.append({"target": config, "pair": name,
|
| 662 |
+
"reason": f"{type(error).__name__}",
|
| 663 |
+
"source": "bouquet"})
|
| 664 |
+
continue
|
| 665 |
+
table = pq.read_table(
|
| 666 |
+
path, columns=["src_text", "tgt_text", "par_id", "domain", "register"]
|
| 667 |
+
)
|
| 668 |
+
for src, trg, par_id, domain, register in zip(
|
| 669 |
+
table.column("src_text").to_pylist(),
|
| 670 |
+
table.column("tgt_text").to_pylist(),
|
| 671 |
+
table.column("par_id").to_pylist(),
|
| 672 |
+
table.column("domain").to_pylist(),
|
| 673 |
+
table.column("register").to_pylist(),
|
| 674 |
+
):
|
| 675 |
+
if not (src or "").strip() or not (trg or "").strip():
|
| 676 |
+
continue
|
| 677 |
+
out.append(make_record(
|
| 678 |
+
pivot_config=pivot_config, target_config=config,
|
| 679 |
+
src=src, trg=trg, source="bouquet", split=split,
|
| 680 |
+
is_src_orig=None,
|
| 681 |
+
extra={"source_variant": level.replace("_level", ""),
|
| 682 |
+
"document_id": str(par_id) if par_id is not None else None,
|
| 683 |
+
"text_domain": domain, "register": register,
|
| 684 |
+
"released_as": "evaluation"},
|
| 685 |
+
))
|
| 686 |
+
return out, skipped
|
| 687 |
+
|
| 688 |
+
|
| 689 |
+
# CODET publishes one file per locality, named for the place rather than the language, so the
|
| 690 |
+
# mapping from place to ISO code has to be stated. Only localities whose variety is one of our
|
| 691 |
+
# targets are listed; the atlas covers 439 in total.
|
| 692 |
+
CODET_LOCALITIES = {
|
| 693 |
+
"nap": ["Marcianise", "Montella", "Napoli", "Ariano%20Irpino", "Gragnano", "Salerno",
|
| 694 |
+
"Torre%20del%20Greco", "Carife", "Trevico", "Calitri", "Bagnoli%20Irpino",
|
| 695 |
+
"Montecalvo%20Irpino", "Scampitella", "Cardito1", "Cardito2", "Cardito3",
|
| 696 |
+
"Cardito4"],
|
| 697 |
+
"lld": ["Corvara", "Selva%20di%20Val%20Gardena", "Pozza%20di%20Fassa", "Ortisei"],
|
| 698 |
+
"pms": ["Torino", "Torino1", "Borgomanero", "Alba", "Mondovi", "Moncalieri", "Poirino",
|
| 699 |
+
"Novi%20Ligure", "Trecate", "Borgofranco%20d%27Ivrea", "Tollegno",
|
| 700 |
+
"Rivarossa%20Canavese"],
|
| 701 |
+
"eml": ["Bologna1", "Bologna2", "Carpi", "Ferrara1", "Mantova", "Bondeno",
|
| 702 |
+
"Bagnolo%20S.%20Vito", "Casalmaggiore", "Luzzara", "Redondesco", "Campagnola",
|
| 703 |
+
"Forli", "Forl%C3%AC", "Cesena2", "Rimini"],
|
| 704 |
+
}
|
| 705 |
+
|
| 706 |
+
|
| 707 |
+
def collect_codet(targets, rows):
|
| 708 |
+
"""CODET's Italian Syntactic Atlas files, aligned by line against standard Italian."""
|
| 709 |
+
base = ("https://raw.githubusercontent.com/mahfuzibnalam/dialect_mt/"
|
| 710 |
+
f"{CODET_REVISION}/Italian")
|
| 711 |
+
standard = fetch(f"{base}/Standard.ita")
|
| 712 |
+
out, skipped = [], []
|
| 713 |
+
if not standard:
|
| 714 |
+
return out, [{"target": None, "pair": "Standard.ita",
|
| 715 |
+
"reason": "not fetchable", "source": "codet"}]
|
| 716 |
+
reference = standard.decode("utf-8", "replace").splitlines()
|
| 717 |
+
ok, _why = pivots.acceptable_pivot("nap", "it", rows)
|
| 718 |
+
if not ok:
|
| 719 |
+
return out, [{"target": None, "pair": "it", "reason": "pivot not acceptable",
|
| 720 |
+
"source": "codet"}]
|
| 721 |
+
for config, localities in CODET_LOCALITIES.items():
|
| 722 |
+
if config not in targets:
|
| 723 |
+
continue
|
| 724 |
+
for locality in localities:
|
| 725 |
+
payload = fetch(f"{base}/{locality}.ita")
|
| 726 |
+
if not payload:
|
| 727 |
+
skipped.append({"target": config, "pair": f"{locality}.ita",
|
| 728 |
+
"reason": "not fetchable", "source": "codet"})
|
| 729 |
+
continue
|
| 730 |
+
lines = payload.decode("utf-8", "replace").splitlines()
|
| 731 |
+
if len(lines) != len(reference):
|
| 732 |
+
# Alignment here is purely positional, so a different length means the file
|
| 733 |
+
# cannot be trusted against the standard text at all.
|
| 734 |
+
skipped.append({"target": config, "pair": f"{locality}.ita",
|
| 735 |
+
"reason": f"{len(lines)} lines against "
|
| 736 |
+
f"{len(reference)} standard",
|
| 737 |
+
"source": "codet"})
|
| 738 |
+
continue
|
| 739 |
+
name = urllib.parse.unquote(locality)
|
| 740 |
+
for index, (dialect, italian) in enumerate(zip(lines, reference)):
|
| 741 |
+
if not dialect.strip() or not italian.strip():
|
| 742 |
+
continue
|
| 743 |
+
out.append(make_record(
|
| 744 |
+
pivot_config="it", target_config=config, src=italian, trg=dialect,
|
| 745 |
+
source="codet", split="test", is_src_orig=True,
|
| 746 |
+
extra={"source_variant": name, "upstream_id": index,
|
| 747 |
+
"locality": name},
|
| 748 |
+
))
|
| 749 |
+
return out, skipped
|
| 750 |
+
|
| 751 |
+
|
| 752 |
+
def collect_dolma_bitext(targets, rows):
|
| 753 |
+
"""DOLMA-NLP's manually aligned pairs: the first human Gilaki sentence bitext."""
|
| 754 |
+
base = ("https://raw.githubusercontent.com/DOLMA-NLP/bitext-mining/"
|
| 755 |
+
f"{DOLMA_BITEXT_REVISION}/datasets/manually-aligned")
|
| 756 |
+
out, skipped = [], []
|
| 757 |
+
for config, filename in (("glk", "GLK-EN.tsv"), ("mzn", "MZN-EN.tsv")):
|
| 758 |
+
if config not in targets:
|
| 759 |
+
continue
|
| 760 |
+
payload = fetch(f"{base}/{filename}")
|
| 761 |
+
if not payload:
|
| 762 |
+
skipped.append({"target": config, "pair": filename,
|
| 763 |
+
"reason": "not fetchable", "source": "dolma_bitext"})
|
| 764 |
+
continue
|
| 765 |
+
ok, _why = pivots.acceptable_pivot(config, "en", rows)
|
| 766 |
+
if not ok:
|
| 767 |
+
continue
|
| 768 |
+
lines = payload.decode("utf-8", "replace").splitlines()
|
| 769 |
+
for index, line in enumerate(lines[1:]): # first line is the header
|
| 770 |
+
parts = line.split("\t")
|
| 771 |
+
if len(parts) < 2 or not parts[0].strip() or not parts[1].strip():
|
| 772 |
+
continue
|
| 773 |
+
out.append(make_record(
|
| 774 |
+
pivot_config="en", target_config=config, src=parts[0], trg=parts[1],
|
| 775 |
+
source="dolma_bitext", split="test", extra={"upstream_id": index},
|
| 776 |
+
))
|
| 777 |
+
return out, skipped
|
| 778 |
+
|
| 779 |
+
|
| 780 |
+
def collect_nllb_seed(targets, rows):
|
| 781 |
+
"""NLLB-Seed's professionally translated sentences, for Buginese."""
|
| 782 |
+
out, skipped = [], []
|
| 783 |
+
if "bug" not in targets:
|
| 784 |
+
return out, skipped
|
| 785 |
+
ok, _why = pivots.acceptable_pivot("bug", "en", rows)
|
| 786 |
+
if not ok:
|
| 787 |
+
return out, skipped
|
| 788 |
+
payload = fetch("https://dl.fbaipublicfiles.com/nllb/NLLB-Seed.zip")
|
| 789 |
+
if not payload:
|
| 790 |
+
return out, [{"target": "bug", "pair": "NLLB-Seed.zip",
|
| 791 |
+
"reason": "not fetchable", "source": "nllb_seed"}]
|
| 792 |
+
try:
|
| 793 |
+
archive = zipfile.ZipFile(io.BytesIO(payload))
|
| 794 |
+
except zipfile.BadZipFile:
|
| 795 |
+
return out, [{"target": "bug", "pair": "NLLB-Seed.zip",
|
| 796 |
+
"reason": "not a zip", "source": "nllb_seed"}]
|
| 797 |
+
names = archive.namelist()
|
| 798 |
+
left = next((n for n in names if n.endswith("/eng_Latn") and "bug_Latn" in n), None)
|
| 799 |
+
right = next((n for n in names if n.endswith("/bug_Latn")), None)
|
| 800 |
+
if not left or not right:
|
| 801 |
+
return out, [{"target": "bug", "pair": "NLLB-Seed",
|
| 802 |
+
"reason": f"no bug_Latn/eng_Latn members among {len(names)} entries",
|
| 803 |
+
"source": "nllb_seed"}]
|
| 804 |
+
src_lines = archive.read(left).decode("utf-8", "replace").splitlines()
|
| 805 |
+
trg_lines = archive.read(right).decode("utf-8", "replace").splitlines()
|
| 806 |
+
if len(src_lines) != len(trg_lines):
|
| 807 |
+
return out, [{"target": "bug", "pair": "NLLB-Seed",
|
| 808 |
+
"reason": f"{len(src_lines)} vs {len(trg_lines)} lines",
|
| 809 |
+
"source": "nllb_seed"}]
|
| 810 |
+
for index, (src, trg) in enumerate(zip(src_lines, trg_lines)):
|
| 811 |
+
if not src.strip() or not trg.strip():
|
| 812 |
+
continue
|
| 813 |
+
out.append(make_record(
|
| 814 |
+
pivot_config="en", target_config="bug", src=src, trg=trg,
|
| 815 |
+
source="nllb_seed", split="test", is_src_orig=True,
|
| 816 |
+
extra={"upstream_id": index},
|
| 817 |
+
))
|
| 818 |
+
return out, skipped
|
| 819 |
+
|
| 820 |
+
|
| 821 |
+
def collect_nusax(targets, rows):
|
| 822 |
+
"""NusaX-MT, twelve-way parallel with official splits. Buginese is the target here."""
|
| 823 |
+
out, skipped = [], []
|
| 824 |
+
if "bug" not in targets:
|
| 825 |
+
return out, skipped
|
| 826 |
+
base = f"https://raw.githubusercontent.com/IndoNLP/nusax/{NUSAX_REVISION}/datasets/mt"
|
| 827 |
+
# NusaX names its columns by language; Indonesian and English are the pivots we keep.
|
| 828 |
+
wanted = {"indonesian": "id", "english": "en"}
|
| 829 |
+
for upstream, split in (("test", "test"), ("valid", "dev")):
|
| 830 |
+
payload = fetch(f"{base}/{upstream}.csv")
|
| 831 |
+
if not payload:
|
| 832 |
+
skipped.append({"target": "bug", "pair": f"{upstream}.csv",
|
| 833 |
+
"reason": "not fetchable", "source": "nusax"})
|
| 834 |
+
continue
|
| 835 |
+
reader = csv.DictReader(io.StringIO(payload.decode("utf-8", "replace")))
|
| 836 |
+
for index, row in enumerate(reader):
|
| 837 |
+
target_text = (row.get("buginese") or "").strip()
|
| 838 |
+
if not target_text:
|
| 839 |
+
continue
|
| 840 |
+
for column, pivot_config in wanted.items():
|
| 841 |
+
src = (row.get(column) or "").strip()
|
| 842 |
+
if not src:
|
| 843 |
+
continue
|
| 844 |
+
ok, _why = pivots.acceptable_pivot("bug", pivot_config, rows)
|
| 845 |
+
if not ok:
|
| 846 |
+
continue
|
| 847 |
+
out.append(make_record(
|
| 848 |
+
pivot_config=pivot_config, target_config="bug",
|
| 849 |
+
src=src, trg=target_text, source="nusax", split=split,
|
| 850 |
+
extra={"upstream_id": index},
|
| 851 |
+
))
|
| 852 |
+
return out, skipped
|
| 853 |
+
|
| 854 |
+
|
| 855 |
+
# Treebanks that carry a free English translation per sentence as a conll comment.
|
| 856 |
+
TREEBANK_TRANSLATIONS = {
|
| 857 |
+
"maibaam": {
|
| 858 |
+
"config": "bar",
|
| 859 |
+
"files": [("https://raw.githubusercontent.com/UniversalDependencies/"
|
| 860 |
+
f"UD_Bavarian-MaiBaam/{MAIBAAM_REVISION}/bar_maibaam-ud-test.conllu",
|
| 861 |
+
"test")],
|
| 862 |
+
},
|
| 863 |
+
"ud_megrelian": {
|
| 864 |
+
"config": "xmf",
|
| 865 |
+
"files": [("https://raw.githubusercontent.com/UniversalDependencies/"
|
| 866 |
+
f"UD_Megrelian-MLC/{UD_MEGRELIAN_REVISION}/xmf_mlc_ud-test.conllu",
|
| 867 |
+
"test")],
|
| 868 |
+
},
|
| 869 |
+
}
|
| 870 |
+
|
| 871 |
+
|
| 872 |
+
def collect_treebank_translations(targets, rows):
|
| 873 |
+
"""Sentences from UD treebanks that ship a '# text_en' free translation."""
|
| 874 |
+
out, skipped = [], []
|
| 875 |
+
for source, spec in TREEBANK_TRANSLATIONS.items():
|
| 876 |
+
config = spec["config"]
|
| 877 |
+
if config not in targets:
|
| 878 |
+
continue
|
| 879 |
+
ok, _why = pivots.acceptable_pivot(config, "en", rows)
|
| 880 |
+
if not ok:
|
| 881 |
+
continue
|
| 882 |
+
for url, split in spec["files"]:
|
| 883 |
+
payload = fetch(url)
|
| 884 |
+
if not payload:
|
| 885 |
+
skipped.append({"target": config, "pair": url.rsplit("/", 1)[-1],
|
| 886 |
+
"reason": "not fetchable", "source": source})
|
| 887 |
+
continue
|
| 888 |
+
text, english, kept = None, None, 0
|
| 889 |
+
for line in payload.decode("utf-8", "replace").splitlines():
|
| 890 |
+
if line.startswith("# text = "):
|
| 891 |
+
text = line[len("# text = "):].strip()
|
| 892 |
+
elif line.startswith("# text_en = "):
|
| 893 |
+
english = line[len("# text_en = "):].strip()
|
| 894 |
+
elif not line.strip():
|
| 895 |
+
if text and english:
|
| 896 |
+
out.append(make_record(
|
| 897 |
+
pivot_config="en", target_config=config,
|
| 898 |
+
src=english, trg=text, source=source, split=split,
|
| 899 |
+
extra={"upstream_id": kept},
|
| 900 |
+
))
|
| 901 |
+
kept += 1
|
| 902 |
+
text, english = None, None
|
| 903 |
+
if text and english:
|
| 904 |
+
out.append(make_record(
|
| 905 |
+
pivot_config="en", target_config=config, src=english, trg=text,
|
| 906 |
+
source=source, split=split, extra={"upstream_id": kept},
|
| 907 |
+
))
|
| 908 |
+
return out, skipped
|
| 909 |
+
|
| 910 |
+
|
| 911 |
+
# Ladin corpora published by Simon Frontull. Only the two with a stated licence are taken;
|
| 912 |
+
# the three undated test sets on the same account state none and are left out rather than
|
| 913 |
+
# guessed at.
|
| 914 |
+
# Only the weather bulletins belong in a test set. The two big ``dizionar`` corpora are
|
| 915 |
+
# lexicographic example sentences harvested from a dictionary -- 37,422 of them, which would
|
| 916 |
+
# be a third of this release and would reward a model for reproducing dictionary glosses
|
| 917 |
+
# rather than translating. They go to the lexicon corpus instead, which is where a reader
|
| 918 |
+
# looking for dictionary material would expect them.
|
| 919 |
+
LADIN_SETS = [
|
| 920 |
+
("ladin_weather", "sfrontull/south-tyrol-weather-lld-deu", "de", "test"),
|
| 921 |
+
]
|
| 922 |
+
|
| 923 |
+
|
| 924 |
+
def collect_ladin(targets, rows):
|
| 925 |
+
"""Italian-Ladin and German-Ladin corpora, including the non-commercial ones."""
|
| 926 |
+
out, skipped = [], []
|
| 927 |
+
if "lld" not in targets:
|
| 928 |
+
return out, skipped
|
| 929 |
+
import pyarrow.parquet as pq
|
| 930 |
+
from huggingface_hub import snapshot_download
|
| 931 |
+
from hf_publishing_auth import publishing_token
|
| 932 |
+
|
| 933 |
+
for source, repo, pivot_config, split in LADIN_SETS:
|
| 934 |
+
ok, _why = pivots.acceptable_pivot("lld", pivot_config, rows)
|
| 935 |
+
if not ok:
|
| 936 |
+
skipped.append({"target": "lld", "pair": repo,
|
| 937 |
+
"reason": "pivot not acceptable", "source": source})
|
| 938 |
+
continue
|
| 939 |
+
try:
|
| 940 |
+
local = snapshot_download(repo, repo_type="dataset",
|
| 941 |
+
token=publishing_token(),
|
| 942 |
+
allow_patterns=["*.parquet", "*.jsonl"])
|
| 943 |
+
except Exception as error: # noqa: BLE001 - gated or absent
|
| 944 |
+
skipped.append({"target": "lld", "pair": repo,
|
| 945 |
+
"reason": f"{type(error).__name__}", "source": source})
|
| 946 |
+
continue
|
| 947 |
+
found = 0
|
| 948 |
+
# Both the parquet and the jsonl releases wrap each pair in a single ``translation``
|
| 949 |
+
# column keyed by language, rather than one column per language.
|
| 950 |
+
pairs: list[dict] = []
|
| 951 |
+
for path in sorted(Path(local).rglob("*.parquet")):
|
| 952 |
+
table = pq.read_table(path)
|
| 953 |
+
if "translation" in table.schema.names:
|
| 954 |
+
pairs += table.column("translation").to_pylist()
|
| 955 |
+
for path in sorted(Path(local).rglob("*.jsonl")):
|
| 956 |
+
with path.open(encoding="utf-8") as handle:
|
| 957 |
+
for line in handle:
|
| 958 |
+
entry = json.loads(line).get("translation")
|
| 959 |
+
if isinstance(entry, dict):
|
| 960 |
+
pairs.append(entry)
|
| 961 |
+
for entry in pairs:
|
| 962 |
+
target_key = next((k for k in entry if k.startswith("lld")), None)
|
| 963 |
+
pivot_key = next((k for k in entry if k.startswith(("ita", "deu"))), None)
|
| 964 |
+
if not target_key or not pivot_key:
|
| 965 |
+
continue
|
| 966 |
+
src, trg = entry.get(pivot_key) or "", entry.get(target_key) or ""
|
| 967 |
+
if not src.strip() or not trg.strip():
|
| 968 |
+
continue
|
| 969 |
+
out.append(make_record(
|
| 970 |
+
pivot_config=pivot_config, target_config="lld", src=src, trg=trg,
|
| 971 |
+
source=source, split=split,
|
| 972 |
+
extra={"source_variant": target_key, "upstream_id": found},
|
| 973 |
+
))
|
| 974 |
+
found += 1
|
| 975 |
+
if not found:
|
| 976 |
+
skipped.append({"target": "lld", "pair": repo,
|
| 977 |
+
"reason": "no recognisable column pair", "source": source})
|
| 978 |
+
return out, skipped
|
| 979 |
+
|
| 980 |
+
|
| 981 |
+
def collect_glotstorybook(targets, rows):
|
| 982 |
+
"""African Storybook texts, aligned to English through their parallel id.
|
| 983 |
+
|
| 984 |
+
Licensing is per row rather than per dataset, so only the plain CC-BY stories are taken;
|
| 985 |
+
the CC-BY-NC and CC-BY-NC-SA ones would silently impose a condition on the whole release.
|
| 986 |
+
"""
|
| 987 |
+
out, skipped = [], []
|
| 988 |
+
if "dag" not in targets:
|
| 989 |
+
return out, skipped
|
| 990 |
+
ok, _why = pivots.acceptable_pivot("dag", "en", rows)
|
| 991 |
+
if not ok:
|
| 992 |
+
return out, skipped
|
| 993 |
+
from huggingface_hub import hf_hub_download
|
| 994 |
+
from hf_publishing_auth import publishing_token
|
| 995 |
+
|
| 996 |
+
try:
|
| 997 |
+
path = hf_hub_download("cis-lmu/GlotStoryBook", "GlotStoryBook.csv",
|
| 998 |
+
repo_type="dataset", token=publishing_token())
|
| 999 |
+
except Exception as error: # noqa: BLE001
|
| 1000 |
+
return out, [{"target": "dag", "pair": "GlotStoryBook.csv",
|
| 1001 |
+
"reason": f"{type(error).__name__}", "source": "glotstorybook"}]
|
| 1002 |
+
|
| 1003 |
+
with open(path, encoding="utf-8") as handle:
|
| 1004 |
+
entries = list(csv.DictReader(handle))
|
| 1005 |
+
# Each story segment is identified by its parallel id plus its position in the story.
|
| 1006 |
+
english = {
|
| 1007 |
+
(row["Parallel ID"], row["Text Number"]): row["Text"]
|
| 1008 |
+
for row in entries if row["ISO639-3"] == "eng"
|
| 1009 |
+
}
|
| 1010 |
+
for row in entries:
|
| 1011 |
+
if row["ISO639-3"] != "dag":
|
| 1012 |
+
continue
|
| 1013 |
+
if (row.get("License") or "").strip().upper().replace(" ", "-") != "CC-BY":
|
| 1014 |
+
skipped.append({"target": "dag", "pair": row.get("File Name"),
|
| 1015 |
+
"reason": f"licence {row.get('License')!r} is not plain CC-BY",
|
| 1016 |
+
"source": "glotstorybook"})
|
| 1017 |
+
continue
|
| 1018 |
+
key = (row["Parallel ID"], row["Text Number"])
|
| 1019 |
+
src = english.get(key)
|
| 1020 |
+
if not src or not (row.get("Text") or "").strip():
|
| 1021 |
+
skipped.append({"target": "dag", "pair": row.get("File Name"),
|
| 1022 |
+
"reason": "no English segment with the same parallel id",
|
| 1023 |
+
"source": "glotstorybook"})
|
| 1024 |
+
continue
|
| 1025 |
+
out.append(make_record(
|
| 1026 |
+
pivot_config="en", target_config="dag", src=src, trg=row["Text"],
|
| 1027 |
+
source="glotstorybook", split="test",
|
| 1028 |
+
extra={"document_id": row["Parallel ID"],
|
| 1029 |
+
"upstream_id": int(row["Text Number"]) if
|
| 1030 |
+
str(row["Text Number"]).isdigit() else None,
|
| 1031 |
+
"source_variant": row.get("Story Category")},
|
| 1032 |
+
))
|
| 1033 |
+
return out, skipped
|
| 1034 |
+
|
| 1035 |
+
|
| 1036 |
+
def collect_nsanku(targets, rows):
|
| 1037 |
+
"""Ghana NLP's Dagbani-English reference pairs, counted but withheld.
|
| 1038 |
+
|
| 1039 |
+
Real human translation and already used as a published evaluation set, but the repository
|
| 1040 |
+
ships no licence and the underlying text is a Bible society translation, so only the row
|
| 1041 |
+
count and provenance are published.
|
| 1042 |
+
"""
|
| 1043 |
+
out, skipped = [], []
|
| 1044 |
+
if "dag" not in targets:
|
| 1045 |
+
return out, skipped
|
| 1046 |
+
ok, _why = pivots.acceptable_pivot("dag", "en", rows)
|
| 1047 |
+
if not ok:
|
| 1048 |
+
return out, skipped
|
| 1049 |
+
payload = fetch("https://raw.githubusercontent.com/GhanaNLP/nsanku/main/input/dag-eng.csv")
|
| 1050 |
+
if not payload:
|
| 1051 |
+
return out, [{"target": "dag", "pair": "input/dag-eng.csv",
|
| 1052 |
+
"reason": "not fetchable", "source": "nsanku"}]
|
| 1053 |
+
reader = csv.reader(io.StringIO(payload.decode("utf-8", "replace")))
|
| 1054 |
+
rows_read = sum(1 for index, line in enumerate(reader) if index and any(line))
|
| 1055 |
+
out.append(make_record(
|
| 1056 |
+
pivot_config="en", target_config="dag", src="", trg="",
|
| 1057 |
+
source="nsanku", split="test",
|
| 1058 |
+
extra={"upstream_rows": rows_read, "upstream_file": "input/dag-eng.csv"},
|
| 1059 |
+
))
|
| 1060 |
+
return out, skipped
|
| 1061 |
+
|
| 1062 |
+
|
| 1063 |
def deduplicate(records, rows):
|
| 1064 |
"""Collapse records that carry the same pair, keeping the most authoritative source.
|
| 1065 |
|
|
|
|
| 1068 |
order follows which release supersedes which, mirroring the ``supersedes`` declarations
|
| 1069 |
in ``configs/community_benchmarks.json``.
|
| 1070 |
"""
|
| 1071 |
+
# Human-authored and manually aligned sources rank above translated-out-of-English ones,
|
| 1072 |
+
# and anything redistributable ranks above a withheld duplicate of the same pair: keeping
|
| 1073 |
+
# the withheld copy would lose text we are allowed to publish.
|
| 1074 |
+
priority = {"bouquet": 0, "dolma_bitext": 1, "nalibasid": 2, "parme": 3, "codet": 4,
|
| 1075 |
+
"nllb_seed": 5, "nusax": 6, "ntrex": 7, "ladin_weather": 8,
|
| 1076 |
+
"ladin_frontull": 9, "maibaam": 10, "ud_megrelian": 11, "xsid": 12,
|
| 1077 |
+
"smol": 13, "tatoeba_challenge": 14,
|
| 1078 |
+
"glotstorybook": 15, "nsanku": 20, "betthupferl": 21, "flores_plus": 22}
|
| 1079 |
best: dict[tuple, dict] = {}
|
| 1080 |
dropped = []
|
| 1081 |
for record in records:
|
| 1082 |
+
if record.get("text_withheld"):
|
| 1083 |
+
# Withheld rows have no text to compare, so they are keyed by what they stand
|
| 1084 |
+
# for: one row per language, source and split.
|
| 1085 |
best[("ref", record["tl"], record["source"], record["split"])] = record
|
| 1086 |
continue
|
| 1087 |
key = (record["tl"], record["sl"], norm_key(record["src"]), norm_key(record["trg"]))
|
|
|
|
| 1114 |
columns = ["sl", "tl", "id", "src", "trg", "is_src_orig", "split", "source",
|
| 1115 |
"source_url", "source_revision", "licence", "domain", "source_pair",
|
| 1116 |
"source_variant", "intent", "variety", "released_as", "upstream_id",
|
| 1117 |
+
"text_withheld", "withheld_reason", "upstream_rows", "upstream_file",
|
| 1118 |
+
"licence_tier", "redistributable", "licence_restriction", "document_id",
|
| 1119 |
+
"text_domain", "register", "locality"]
|
| 1120 |
schema = pa.schema([
|
| 1121 |
("sl", pa.string()), ("tl", pa.string()), ("id", pa.int64()),
|
| 1122 |
("src", pa.string()), ("trg", pa.string()), ("is_src_orig", pa.bool_()),
|
|
|
|
| 1127 |
("upstream_id", pa.int64()), ("text_withheld", pa.bool_()),
|
| 1128 |
("withheld_reason", pa.string()), ("upstream_rows", pa.int64()),
|
| 1129 |
("upstream_file", pa.string()),
|
| 1130 |
+
# How freely each record may be passed on, and the structure some sources carry.
|
| 1131 |
+
("licence_tier", pa.int64()), ("redistributable", pa.bool_()),
|
| 1132 |
+
("licence_restriction", pa.string()), ("document_id", pa.string()),
|
| 1133 |
+
("text_domain", pa.string()), ("register", pa.string()),
|
| 1134 |
+
("locality", pa.string()),
|
| 1135 |
])
|
| 1136 |
|
| 1137 |
summary, flat = {}, []
|
|
|
|
| 1250 |
("nalibasid", lambda: collect_nalibasid(rows)),
|
| 1251 |
("parme", lambda: collect_parme(rows)),
|
| 1252 |
("smol", lambda: collect_smol(targets, rows)),
|
| 1253 |
+
("bouquet", lambda: collect_bouquet(targets, rows)),
|
| 1254 |
+
("codet", lambda: collect_codet(targets, rows)),
|
| 1255 |
+
("dolma_bitext", lambda: collect_dolma_bitext(targets, rows)),
|
| 1256 |
+
("nllb_seed", lambda: collect_nllb_seed(targets, rows)),
|
| 1257 |
+
("nusax", lambda: collect_nusax(targets, rows)),
|
| 1258 |
+
("treebanks", lambda: collect_treebank_translations(targets, rows)),
|
| 1259 |
+
("ladin", lambda: collect_ladin(targets, rows)),
|
| 1260 |
+
("glotstorybook", lambda: collect_glotstorybook(targets, rows)),
|
| 1261 |
+
("nsanku", lambda: collect_nsanku(targets, rows)),
|
| 1262 |
):
|
| 1263 |
got, missed = collector()
|
| 1264 |
print(f" {label:<20} {len(got):>7,} records, {len(missed)} skipped", flush=True)
|
| 1265 |
records += got
|
| 1266 |
+
# Two labels cover more than one source, so the entry's own source wins.
|
| 1267 |
+
skipped += [{"source": label, **entry} for entry in missed]
|
| 1268 |
|
| 1269 |
references = collect_flores_reference(targets, rows)
|
| 1270 |
print(f" {'flores_plus (ref)':<20} {len(references):>7,} reference rows", flush=True)
|
scripts/build_lexicon_corpus.py
ADDED
|
@@ -0,0 +1,713 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Gather lexicons, glossaries and glossed material for the audit's shortlist languages.
|
| 2 |
+
|
| 3 |
+
The evaluation corpus answers "can this model translate?". This one answers the question that
|
| 4 |
+
comes first for a language with almost no parallel text: what word-level evidence exists at
|
| 5 |
+
all. Bilingual dictionaries, parallel wordlists, dictionary example sentences and token-level
|
| 6 |
+
glosses are what a translation system for these languages can actually be seeded from, and
|
| 7 |
+
for several of them it is the only human-curated material in existence.
|
| 8 |
+
|
| 9 |
+
Records keep the same shape as the evaluation corpus -- ``sl``, ``tl``, ``src``, ``trg`` plus
|
| 10 |
+
provenance -- so the two can be read with one reader. ``entry_type`` says what a row really
|
| 11 |
+
is, because a dictionary headword, a multiword gloss and a full example sentence are not
|
| 12 |
+
interchangeable evidence:
|
| 13 |
+
|
| 14 |
+
* ``word`` a single-word headword and its translation
|
| 15 |
+
* ``phrase`` a multiword headword or gloss
|
| 16 |
+
* ``example_sentence`` a sentence illustrating a headword, from a dictionary
|
| 17 |
+
* ``token_gloss`` one token of a sentence glossed into another language
|
| 18 |
+
|
| 19 |
+
Pairing follows the same pivot rule as everywhere else in this project: English, plus the
|
| 20 |
+
high-resource or related neighbours that the audit found contribute materially to a language.
|
| 21 |
+
That is why Gilaki is paired with Persian here and Ladin with Italian and German.
|
| 22 |
+
|
| 23 |
+
Licence tiers are inherited from ``build_eval_corpus``: tier 1 is republishable, tier 2 is
|
| 24 |
+
republishable under a restriction (non-commercial), tier 3 is counted with the text withheld.
|
| 25 |
+
GPL-3.0 sources are tier 2 rather than tier 1 -- Apertium's dictionaries are the largest
|
| 26 |
+
hand-written resource for several of these languages, but a copyleft licence is a real
|
| 27 |
+
condition on reuse and should not be hidden inside a mixed release.
|
| 28 |
+
"""
|
| 29 |
+
|
| 30 |
+
from __future__ import annotations
|
| 31 |
+
|
| 32 |
+
import argparse
|
| 33 |
+
import csv
|
| 34 |
+
import io
|
| 35 |
+
import json
|
| 36 |
+
import re
|
| 37 |
+
import sys
|
| 38 |
+
import time
|
| 39 |
+
import xml.etree.ElementTree as ElementTree
|
| 40 |
+
from pathlib import Path
|
| 41 |
+
|
| 42 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 43 |
+
sys.path.insert(0, str(ROOT / "scripts"))
|
| 44 |
+
|
| 45 |
+
import shortlist_pivots as pivots # noqa: E402
|
| 46 |
+
from build_eval_corpus import ( # noqa: E402
|
| 47 |
+
TIER_REDISTRIBUTABLE,
|
| 48 |
+
TIER_REFERENCE,
|
| 49 |
+
TIER_RESTRICTED,
|
| 50 |
+
_clean,
|
| 51 |
+
fetch,
|
| 52 |
+
norm_key,
|
| 53 |
+
)
|
| 54 |
+
from corpus_subsets import subset_name, write_subsets # noqa: E402
|
| 55 |
+
|
| 56 |
+
DIST = ROOT / "dist" / "lexicon_corpus"
|
| 57 |
+
|
| 58 |
+
CHIKHAPO_REVISION = "main"
|
| 59 |
+
APERTIUM_REVISION = "master"
|
| 60 |
+
DIVITAL_REVISION = "master"
|
| 61 |
+
GILAKI_TOP1000_REVISION = "master"
|
| 62 |
+
|
| 63 |
+
SOURCE_META = {
|
| 64 |
+
"chikhapo": {
|
| 65 |
+
"url": "https://huggingface.co/datasets/ec5ug/chikhapo",
|
| 66 |
+
"revision": CHIKHAPO_REVISION, "licence": "MIT",
|
| 67 |
+
"note": "Word-level bilingual lexicons assembled from PanLex, GATITOS and the "
|
| 68 |
+
"Intercontinental Dictionary Series. Covers 21 of the 22 languages -- Gilaki "
|
| 69 |
+
"is the exception, which is why it needs its own sources here.",
|
| 70 |
+
"tier": TIER_REDISTRIBUTABLE,
|
| 71 |
+
},
|
| 72 |
+
"gatitos": {
|
| 73 |
+
"url": "https://huggingface.co/datasets/google/smol",
|
| 74 |
+
"revision": "main", "licence": "CC-BY-4.0",
|
| 75 |
+
"note": "Google's GATITOS bilingual lexicons: short, high-frequency, professionally "
|
| 76 |
+
"translated token pairs.",
|
| 77 |
+
"tier": TIER_REDISTRIBUTABLE,
|
| 78 |
+
},
|
| 79 |
+
"nusax_lexicon": {
|
| 80 |
+
"url": "https://github.com/IndoNLP/nusax",
|
| 81 |
+
"revision": "main", "licence": "CC-BY-SA-4.0",
|
| 82 |
+
"note": "Indonesian-Buginese wordlist from NusaX, translated by native speakers.",
|
| 83 |
+
"tier": TIER_REDISTRIBUTABLE,
|
| 84 |
+
},
|
| 85 |
+
"gilaki_top1000": {
|
| 86 |
+
"url": "https://github.com/LordArma/Top-1000-Words-in-Gilaki",
|
| 87 |
+
"revision": GILAKI_TOP1000_REVISION, "licence": "GPL-3.0",
|
| 88 |
+
"note": "The thousand most frequent Gilaki words, each with a Persian and English "
|
| 89 |
+
"equivalent and an example sentence in all three languages. One of only two "
|
| 90 |
+
"machine-readable Gilaki lexicons found anywhere.",
|
| 91 |
+
"tier": TIER_RESTRICTED,
|
| 92 |
+
"restriction": "GPL-3.0: derived distributions inherit copyleft terms.",
|
| 93 |
+
},
|
| 94 |
+
"apertium": {
|
| 95 |
+
"url": "https://github.com/apertium",
|
| 96 |
+
"revision": APERTIUM_REVISION, "licence": "GPL-3.0",
|
| 97 |
+
"note": "Hand-written bilingual dictionaries from rule-based MT pairs. The largest "
|
| 98 |
+
"curated bilingual lexicon for Scots and for Interlingua.",
|
| 99 |
+
"tier": TIER_RESTRICTED,
|
| 100 |
+
"restriction": "GPL-3.0: derived distributions inherit copyleft terms.",
|
| 101 |
+
},
|
| 102 |
+
"ladin_dizionar": {
|
| 103 |
+
"url": "https://huggingface.co/sfrontull",
|
| 104 |
+
"revision": "main", "licence": "CC-BY-NC-SA-4.0",
|
| 105 |
+
"note": "Example sentences from the Istitut Ladin Micurà de Rü dictionaries, for Val "
|
| 106 |
+
"Badia and Gherdeina Ladin against Italian. Dictionary examples rather than "
|
| 107 |
+
"running text, which is why they are here and not in the evaluation corpus.",
|
| 108 |
+
"tier": TIER_RESTRICTED,
|
| 109 |
+
"restriction": "Non-commercial use only.",
|
| 110 |
+
},
|
| 111 |
+
"divital": {
|
| 112 |
+
"url": "https://github.com/UniversalDependencies/UD_Alemannic-DIVITAL",
|
| 113 |
+
"revision": DIVITAL_REVISION, "licence": "CC-BY-SA-4.0",
|
| 114 |
+
"note": "Token-level French glosses and German lemmas on the Alsatian Low Alemannic "
|
| 115 |
+
"treebank. Genuine interlinear glossing, paired with French rather than "
|
| 116 |
+
"German.",
|
| 117 |
+
"tier": TIER_REDISTRIBUTABLE,
|
| 118 |
+
},
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
for _meta in SOURCE_META.values():
|
| 122 |
+
_meta.setdefault("tier", TIER_REDISTRIBUTABLE)
|
| 123 |
+
_meta.setdefault("restriction", None)
|
| 124 |
+
|
| 125 |
+
# ChiKhaPo and the audit disagree on a few codes; ChiKhaPo files are named by ISO 639-3.
|
| 126 |
+
ISO_FOR_CONFIG = {
|
| 127 |
+
"als": "gsw", "bat_smg": "sgs", "vo": "vol", "ie": "ile", "ia": "ina",
|
| 128 |
+
"nv": "nav", "eml": "egl",
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def iso_of(config: str, rows: dict) -> str:
|
| 133 |
+
return ISO_FOR_CONFIG.get(config) or (rows.get(config) or {}).get("iso639_3") or config
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def make_entry(*, pivot_config, target_config, src, trg, source, entry_type,
|
| 137 |
+
extra=None) -> dict:
|
| 138 |
+
meta = SOURCE_META[source]
|
| 139 |
+
record = {
|
| 140 |
+
"sl": pivot_config,
|
| 141 |
+
"tl": target_config,
|
| 142 |
+
"id": None,
|
| 143 |
+
"src": _clean(src),
|
| 144 |
+
"trg": _clean(trg),
|
| 145 |
+
"entry_type": entry_type,
|
| 146 |
+
"split": "lexicon",
|
| 147 |
+
"source": source,
|
| 148 |
+
"source_url": meta["url"],
|
| 149 |
+
"source_revision": meta["revision"],
|
| 150 |
+
"licence": meta["licence"],
|
| 151 |
+
"licence_tier": meta["tier"],
|
| 152 |
+
"redistributable": meta["tier"] != TIER_REFERENCE,
|
| 153 |
+
"licence_restriction": meta["restriction"],
|
| 154 |
+
}
|
| 155 |
+
if extra:
|
| 156 |
+
record.update(extra)
|
| 157 |
+
if meta["tier"] == TIER_REFERENCE:
|
| 158 |
+
record["src"], record["trg"] = "", ""
|
| 159 |
+
record["text_withheld"] = True
|
| 160 |
+
return record
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
def _entry_type(text: str) -> str:
|
| 164 |
+
"""A headword, a multiword gloss and a sentence are different kinds of evidence."""
|
| 165 |
+
stripped = (text or "").strip()
|
| 166 |
+
if not stripped:
|
| 167 |
+
return "word"
|
| 168 |
+
if re.search(r"[.!?؟。]\s*$", stripped) or len(stripped.split()) > 6:
|
| 169 |
+
return "example_sentence"
|
| 170 |
+
return "word" if len(stripped.split()) == 1 else "phrase"
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
# ------------------------------------------------------------------------------ collectors
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
def collect_chikhapo(targets, rows):
|
| 177 |
+
"""ChiKhaPo's per-language lexicons, in both directions, against English."""
|
| 178 |
+
from huggingface_hub import hf_hub_download
|
| 179 |
+
from hf_publishing_auth import publishing_token
|
| 180 |
+
|
| 181 |
+
out, skipped = [], []
|
| 182 |
+
token = publishing_token()
|
| 183 |
+
for config in targets:
|
| 184 |
+
iso = iso_of(config, rows)
|
| 185 |
+
ok, _why = pivots.acceptable_pivot(config, "en", rows)
|
| 186 |
+
if not ok:
|
| 187 |
+
continue
|
| 188 |
+
for name, forward in ((f"data/{iso}_eng.jsonl", True), (f"data/eng_{iso}.jsonl", False)):
|
| 189 |
+
try:
|
| 190 |
+
path = hf_hub_download("ec5ug/chikhapo", name, repo_type="dataset",
|
| 191 |
+
token=token)
|
| 192 |
+
except Exception as error: # noqa: BLE001 - language absent from the release
|
| 193 |
+
skipped.append({"target": config, "pair": name,
|
| 194 |
+
"reason": f"{type(error).__name__}", "source": "chikhapo"})
|
| 195 |
+
continue
|
| 196 |
+
with open(path, encoding="utf-8") as handle:
|
| 197 |
+
for index, line in enumerate(handle):
|
| 198 |
+
entry = json.loads(line)
|
| 199 |
+
head = entry.get("source_word") or ""
|
| 200 |
+
for sense, translation in enumerate(entry.get("target_translations") or []):
|
| 201 |
+
if not head.strip() or not (translation or "").strip():
|
| 202 |
+
continue
|
| 203 |
+
# Always emit as pivot -> target, whichever way the file reads.
|
| 204 |
+
src, trg = (translation, head) if forward else (head, translation)
|
| 205 |
+
out.append(make_entry(
|
| 206 |
+
pivot_config="en", target_config=config, src=src, trg=trg,
|
| 207 |
+
source="chikhapo", entry_type=_entry_type(trg),
|
| 208 |
+
extra={"sense_index": sense, "upstream_id": index,
|
| 209 |
+
"upstream_file": name},
|
| 210 |
+
))
|
| 211 |
+
return out, skipped
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
def collect_gatitos(targets, rows):
|
| 215 |
+
"""GATITOS bilingual lexicons for the languages that have one."""
|
| 216 |
+
out, skipped = [], []
|
| 217 |
+
for config in targets:
|
| 218 |
+
iso = iso_of(config, rows)
|
| 219 |
+
ok, _why = pivots.acceptable_pivot(config, "en", rows)
|
| 220 |
+
if not ok:
|
| 221 |
+
continue
|
| 222 |
+
for code in dict.fromkeys([iso, config]):
|
| 223 |
+
name = f"gatitos/en_{code}.jsonl"
|
| 224 |
+
payload = fetch(
|
| 225 |
+
f"https://huggingface.co/datasets/google/smol/resolve/main/{name}", auth=True
|
| 226 |
+
)
|
| 227 |
+
if not payload:
|
| 228 |
+
continue
|
| 229 |
+
for index, line in enumerate(payload.decode("utf-8", "replace").splitlines()):
|
| 230 |
+
if not line.strip():
|
| 231 |
+
continue
|
| 232 |
+
entry = json.loads(line)
|
| 233 |
+
head = entry.get("src") or ""
|
| 234 |
+
for sense, translation in enumerate(entry.get("trgs") or []):
|
| 235 |
+
if not head.strip() or not (translation or "").strip():
|
| 236 |
+
continue
|
| 237 |
+
out.append(make_entry(
|
| 238 |
+
pivot_config="en", target_config=config,
|
| 239 |
+
src=head, trg=translation, source="gatitos",
|
| 240 |
+
entry_type=_entry_type(translation),
|
| 241 |
+
extra={"sense_index": sense, "upstream_id": index,
|
| 242 |
+
"upstream_file": name},
|
| 243 |
+
))
|
| 244 |
+
break
|
| 245 |
+
else:
|
| 246 |
+
skipped.append({"target": config, "pair": f"gatitos/en_{iso}.jsonl",
|
| 247 |
+
"reason": "no GATITOS lexicon", "source": "gatitos"})
|
| 248 |
+
return out, skipped
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
def collect_nusax_lexicon(targets, rows):
|
| 252 |
+
"""NusaX's Indonesian-Buginese wordlist."""
|
| 253 |
+
out, skipped = [], []
|
| 254 |
+
if "bug" not in targets:
|
| 255 |
+
return out, skipped
|
| 256 |
+
ok, _why = pivots.acceptable_pivot("bug", "id", rows)
|
| 257 |
+
if not ok:
|
| 258 |
+
return out, skipped
|
| 259 |
+
payload = fetch("https://raw.githubusercontent.com/IndoNLP/nusax/main/"
|
| 260 |
+
"datasets/lexicon/buginese.csv")
|
| 261 |
+
if not payload:
|
| 262 |
+
return out, [{"target": "bug", "pair": "lexicon/buginese.csv",
|
| 263 |
+
"reason": "not fetchable", "source": "nusax_lexicon"}]
|
| 264 |
+
reader = csv.reader(io.StringIO(payload.decode("utf-8", "replace")))
|
| 265 |
+
for index, line in enumerate(reader):
|
| 266 |
+
if index == 0 or len(line) < 2:
|
| 267 |
+
continue
|
| 268 |
+
indonesian, buginese = line[0].strip(), line[1].strip()
|
| 269 |
+
if not indonesian or not buginese:
|
| 270 |
+
continue
|
| 271 |
+
out.append(make_entry(
|
| 272 |
+
pivot_config="id", target_config="bug", src=indonesian, trg=buginese,
|
| 273 |
+
source="nusax_lexicon", entry_type=_entry_type(buginese),
|
| 274 |
+
extra={"upstream_id": index},
|
| 275 |
+
))
|
| 276 |
+
return out, skipped
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
def collect_gilaki_top1000(targets, rows):
|
| 280 |
+
"""The Gilaki frequency list: words and example sentences against Persian and English."""
|
| 281 |
+
out, skipped = [], []
|
| 282 |
+
if "glk" not in targets:
|
| 283 |
+
return out, skipped
|
| 284 |
+
# The default branch is master, not main, and the filename contains spaces.
|
| 285 |
+
name = "Top%201000%20Words%20in%20Gilaki.json"
|
| 286 |
+
payload = fetch("https://raw.githubusercontent.com/LordArma/Top-1000-Words-in-Gilaki/"
|
| 287 |
+
f"{GILAKI_TOP1000_REVISION}/JSON/{name}")
|
| 288 |
+
if not payload:
|
| 289 |
+
return out, [{"target": "glk", "pair": name, "reason": "not fetchable",
|
| 290 |
+
"source": "gilaki_top1000"}]
|
| 291 |
+
try:
|
| 292 |
+
entries = json.loads(payload.decode("utf-8", "replace"))
|
| 293 |
+
except json.JSONDecodeError as error:
|
| 294 |
+
return out, [{"target": "glk", "pair": name, "reason": f"invalid JSON: {error}",
|
| 295 |
+
"source": "gilaki_top1000"}]
|
| 296 |
+
|
| 297 |
+
def value(entry, key):
|
| 298 |
+
got = entry.get(key)
|
| 299 |
+
return got.strip() if isinstance(got, str) else ""
|
| 300 |
+
|
| 301 |
+
for entry in entries:
|
| 302 |
+
if not isinstance(entry, dict):
|
| 303 |
+
continue
|
| 304 |
+
gilaki = value(entry, "glk_word")
|
| 305 |
+
gilaki_example = value(entry, "glk_example")
|
| 306 |
+
index = entry.get("id")
|
| 307 |
+
for pivot_config, prefix in (("fa", "fa"), ("en", "en")):
|
| 308 |
+
ok, _why = pivots.acceptable_pivot("glk", pivot_config, rows)
|
| 309 |
+
if not ok:
|
| 310 |
+
continue
|
| 311 |
+
word = value(entry, f"{prefix}_word")
|
| 312 |
+
if gilaki and word:
|
| 313 |
+
out.append(make_entry(
|
| 314 |
+
pivot_config=pivot_config, target_config="glk",
|
| 315 |
+
src=word, trg=gilaki, source="gilaki_top1000",
|
| 316 |
+
entry_type="word",
|
| 317 |
+
extra={"upstream_id": index, "upstream_file": "JSON/" + name},
|
| 318 |
+
))
|
| 319 |
+
# The example sentences are the more valuable half: real Gilaki syntax, and the
|
| 320 |
+
# only Gilaki-Persian sentence pairs in this corpus.
|
| 321 |
+
example = value(entry, f"{prefix}_example")
|
| 322 |
+
if gilaki_example and example:
|
| 323 |
+
out.append(make_entry(
|
| 324 |
+
pivot_config=pivot_config, target_config="glk",
|
| 325 |
+
src=example, trg=gilaki_example, source="gilaki_top1000",
|
| 326 |
+
entry_type="example_sentence",
|
| 327 |
+
extra={"upstream_id": index, "upstream_file": "JSON/" + name},
|
| 328 |
+
))
|
| 329 |
+
return out, skipped
|
| 330 |
+
|
| 331 |
+
|
| 332 |
+
# Apertium bilingual dictionaries worth taking, as (repo, left code, right code). Only pairs
|
| 333 |
+
# where one side is a shortlist language and the other is an acceptable pivot.
|
| 334 |
+
APERTIUM_PAIRS = [
|
| 335 |
+
("apertium-eng-sco", "eng", "sco", "sco", "en"),
|
| 336 |
+
("apertium-eng-ina", "eng", "ina", "ia", "en"),
|
| 337 |
+
("apertium-spa-ina", "spa", "ina", "ia", "es"),
|
| 338 |
+
("apertium-fra-ina", "fra", "ina", "ia", "fr"),
|
| 339 |
+
("apertium-por-ina", "por", "ina", "ia", "pt"),
|
| 340 |
+
("apertium-deu-ina", "deu", "ina", "ia", "de"),
|
| 341 |
+
("apertium-cat-ina", "cat", "ina", "ia", "ca"),
|
| 342 |
+
("apertium-ron-ina", "ron", "ina", "ia", "ro"),
|
| 343 |
+
]
|
| 344 |
+
|
| 345 |
+
|
| 346 |
+
def _dix_pairs(payload: bytes, left: str, right: str) -> list[tuple[str, str]]:
|
| 347 |
+
"""Left/right pairs from an Apertium bilingual dictionary."""
|
| 348 |
+
try:
|
| 349 |
+
tree = ElementTree.fromstring(payload)
|
| 350 |
+
except ElementTree.ParseError:
|
| 351 |
+
return []
|
| 352 |
+
pairs = []
|
| 353 |
+
for entry in tree.iter("e"):
|
| 354 |
+
pair = entry.find("p")
|
| 355 |
+
if pair is None:
|
| 356 |
+
# A shared-form entry: one <i> standing for both sides.
|
| 357 |
+
shared = entry.find("i")
|
| 358 |
+
if shared is not None:
|
| 359 |
+
text = "".join(shared.itertext()).strip()
|
| 360 |
+
if text:
|
| 361 |
+
pairs.append((text, text))
|
| 362 |
+
continue
|
| 363 |
+
left_node, right_node = pair.find("l"), pair.find("r")
|
| 364 |
+
if left_node is None or right_node is None:
|
| 365 |
+
continue
|
| 366 |
+
left_text = "".join(left_node.itertext()).strip()
|
| 367 |
+
right_text = "".join(right_node.itertext()).strip()
|
| 368 |
+
if left_text and right_text:
|
| 369 |
+
pairs.append((left_text, right_text))
|
| 370 |
+
return pairs
|
| 371 |
+
|
| 372 |
+
|
| 373 |
+
def collect_apertium(targets, rows):
|
| 374 |
+
"""Hand-written Apertium bilingual dictionaries."""
|
| 375 |
+
out, skipped = [], []
|
| 376 |
+
for repo, left, right, config, pivot_config in APERTIUM_PAIRS:
|
| 377 |
+
if config not in targets:
|
| 378 |
+
continue
|
| 379 |
+
ok, _why = pivots.acceptable_pivot(config, pivot_config, rows)
|
| 380 |
+
if not ok:
|
| 381 |
+
skipped.append({"target": config, "pair": repo,
|
| 382 |
+
"reason": "pivot not acceptable", "source": "apertium"})
|
| 383 |
+
continue
|
| 384 |
+
name = f"{repo}.{left}-{right}.dix"
|
| 385 |
+
payload = fetch(f"https://raw.githubusercontent.com/apertium/{repo}/"
|
| 386 |
+
f"{APERTIUM_REVISION}/{name}")
|
| 387 |
+
if not payload:
|
| 388 |
+
skipped.append({"target": config, "pair": name, "reason": "not fetchable",
|
| 389 |
+
"source": "apertium"})
|
| 390 |
+
continue
|
| 391 |
+
found = _dix_pairs(payload, left, right)
|
| 392 |
+
if not found:
|
| 393 |
+
skipped.append({"target": config, "pair": name,
|
| 394 |
+
"reason": "no parsable entries", "source": "apertium"})
|
| 395 |
+
continue
|
| 396 |
+
for index, (pivot_word, target_word) in enumerate(found):
|
| 397 |
+
out.append(make_entry(
|
| 398 |
+
pivot_config=pivot_config, target_config=config,
|
| 399 |
+
src=pivot_word, trg=target_word, source="apertium",
|
| 400 |
+
entry_type=_entry_type(target_word),
|
| 401 |
+
extra={"upstream_id": index, "upstream_file": name},
|
| 402 |
+
))
|
| 403 |
+
return out, skipped
|
| 404 |
+
|
| 405 |
+
|
| 406 |
+
LADIN_DICTIONARIES = [
|
| 407 |
+
("sfrontull/lld_valbadia-ita", "it"),
|
| 408 |
+
("sfrontull/lld_gherd-ita", "it"),
|
| 409 |
+
("sfrontull/lld_valbadia-lld_gherd", "lld"),
|
| 410 |
+
]
|
| 411 |
+
|
| 412 |
+
|
| 413 |
+
def collect_ladin_dizionar(targets, rows):
|
| 414 |
+
"""Dictionary example sentences for the two main Ladin varieties."""
|
| 415 |
+
out, skipped = [], []
|
| 416 |
+
if "lld" not in targets:
|
| 417 |
+
return out, skipped
|
| 418 |
+
import pyarrow.parquet as pq
|
| 419 |
+
from huggingface_hub import snapshot_download
|
| 420 |
+
from hf_publishing_auth import publishing_token
|
| 421 |
+
|
| 422 |
+
for repo, pivot_config in LADIN_DICTIONARIES:
|
| 423 |
+
if pivot_config != "lld":
|
| 424 |
+
ok, _why = pivots.acceptable_pivot("lld", pivot_config, rows)
|
| 425 |
+
if not ok:
|
| 426 |
+
skipped.append({"target": "lld", "pair": repo,
|
| 427 |
+
"reason": "pivot not acceptable",
|
| 428 |
+
"source": "ladin_dizionar"})
|
| 429 |
+
continue
|
| 430 |
+
try:
|
| 431 |
+
local = snapshot_download(repo, repo_type="dataset",
|
| 432 |
+
token=publishing_token(),
|
| 433 |
+
allow_patterns=["*.parquet"])
|
| 434 |
+
except Exception as error: # noqa: BLE001
|
| 435 |
+
skipped.append({"target": "lld", "pair": repo,
|
| 436 |
+
"reason": f"{type(error).__name__}",
|
| 437 |
+
"source": "ladin_dizionar"})
|
| 438 |
+
continue
|
| 439 |
+
found = 0
|
| 440 |
+
for path in sorted(Path(local).rglob("*.parquet")):
|
| 441 |
+
table = pq.read_table(path)
|
| 442 |
+
if "translation" not in table.schema.names:
|
| 443 |
+
continue
|
| 444 |
+
for entry in table.column("translation").to_pylist():
|
| 445 |
+
if not isinstance(entry, dict):
|
| 446 |
+
continue
|
| 447 |
+
keys = sorted(entry)
|
| 448 |
+
if pivot_config == "lld":
|
| 449 |
+
# The intra-Ladin set: Val Badia against Gherdeina.
|
| 450 |
+
pivot_key = next((k for k in keys if k.endswith("gherd")), None)
|
| 451 |
+
target_key = next((k for k in keys if k.endswith("valbadia")), None)
|
| 452 |
+
else:
|
| 453 |
+
pivot_key = next((k for k in keys if k.startswith(("ita", "deu"))), None)
|
| 454 |
+
target_key = next((k for k in keys if k.startswith("lld")), None)
|
| 455 |
+
if not pivot_key or not target_key:
|
| 456 |
+
continue
|
| 457 |
+
src, trg = entry.get(pivot_key) or "", entry.get(target_key) or ""
|
| 458 |
+
if not src.strip() or not trg.strip():
|
| 459 |
+
continue
|
| 460 |
+
out.append(make_entry(
|
| 461 |
+
pivot_config=pivot_config, target_config="lld", src=src, trg=trg,
|
| 462 |
+
source="ladin_dizionar", entry_type=_entry_type(trg),
|
| 463 |
+
extra={"upstream_id": found, "source_variant": target_key,
|
| 464 |
+
"upstream_file": repo},
|
| 465 |
+
))
|
| 466 |
+
found += 1
|
| 467 |
+
if not found:
|
| 468 |
+
skipped.append({"target": "lld", "pair": repo,
|
| 469 |
+
"reason": "no translation column", "source": "ladin_dizionar"})
|
| 470 |
+
return out, skipped
|
| 471 |
+
|
| 472 |
+
|
| 473 |
+
def collect_divital(targets, rows):
|
| 474 |
+
"""Token-level French glosses from the Alsatian Low Alemannic treebank."""
|
| 475 |
+
out, skipped = [], []
|
| 476 |
+
if "als" not in targets:
|
| 477 |
+
return out, skipped
|
| 478 |
+
ok, _why = pivots.acceptable_pivot("als", "fr", rows)
|
| 479 |
+
if not ok:
|
| 480 |
+
skipped.append({"target": "als", "pair": "DIVITAL", "reason": "pivot not acceptable",
|
| 481 |
+
"source": "divital"})
|
| 482 |
+
return out, skipped
|
| 483 |
+
payload = fetch("https://raw.githubusercontent.com/UniversalDependencies/"
|
| 484 |
+
f"UD_Alemannic-DIVITAL/{DIVITAL_REVISION}/gsw_divital-ud-test.conllu")
|
| 485 |
+
if not payload:
|
| 486 |
+
return out, [{"target": "als", "pair": "gsw_divital-ud-test.conllu",
|
| 487 |
+
"reason": "not fetchable", "source": "divital"}]
|
| 488 |
+
for index, line in enumerate(payload.decode("utf-8", "replace").splitlines()):
|
| 489 |
+
if not line.strip() or line.startswith("#"):
|
| 490 |
+
continue
|
| 491 |
+
fields = line.split("\t")
|
| 492 |
+
if len(fields) < 10:
|
| 493 |
+
continue
|
| 494 |
+
form, misc = fields[1], fields[9]
|
| 495 |
+
gloss = None
|
| 496 |
+
for item in misc.split("|"):
|
| 497 |
+
if item.startswith("Gloss[fr]="):
|
| 498 |
+
gloss = item[len("Gloss[fr]="):]
|
| 499 |
+
break
|
| 500 |
+
if not form.strip() or not gloss or not gloss.strip():
|
| 501 |
+
continue
|
| 502 |
+
out.append(make_entry(
|
| 503 |
+
pivot_config="fr", target_config="als", src=gloss, trg=form,
|
| 504 |
+
source="divital", entry_type="token_gloss",
|
| 505 |
+
extra={"upstream_id": index},
|
| 506 |
+
))
|
| 507 |
+
return out, skipped
|
| 508 |
+
|
| 509 |
+
|
| 510 |
+
# ------------------------------------------------------------------- de-duplication & output
|
| 511 |
+
|
| 512 |
+
|
| 513 |
+
def deduplicate(entries):
|
| 514 |
+
"""Collapse identical pairs, keeping the most freely licensed copy.
|
| 515 |
+
|
| 516 |
+
The same PanLex-derived pair reaches us through ChiKhaPo and GATITOS, and the Apertium
|
| 517 |
+
dictionaries overlap both. Keeping the tier-1 copy matters: preferring a GPL or
|
| 518 |
+
non-commercial duplicate would impose its condition on data we could otherwise publish
|
| 519 |
+
freely.
|
| 520 |
+
"""
|
| 521 |
+
best: dict[tuple, dict] = {}
|
| 522 |
+
dropped = []
|
| 523 |
+
for entry in entries:
|
| 524 |
+
key = (entry["tl"], entry["sl"], norm_key(entry["src"]), norm_key(entry["trg"]))
|
| 525 |
+
incumbent = best.get(key)
|
| 526 |
+
if incumbent is None:
|
| 527 |
+
best[key] = entry
|
| 528 |
+
continue
|
| 529 |
+
if entry["licence_tier"] < incumbent["licence_tier"]:
|
| 530 |
+
dropped.append({"kept": entry["source"], "dropped": incumbent["source"],
|
| 531 |
+
"language": entry["tl"]})
|
| 532 |
+
best[key] = entry
|
| 533 |
+
else:
|
| 534 |
+
dropped.append({"kept": incumbent["source"], "dropped": entry["source"],
|
| 535 |
+
"language": entry["tl"]})
|
| 536 |
+
return list(best.values()), dropped
|
| 537 |
+
|
| 538 |
+
|
| 539 |
+
COLUMNS = ["sl", "tl", "id", "src", "trg", "entry_type", "split", "source", "source_url",
|
| 540 |
+
"source_revision", "licence", "licence_tier", "redistributable",
|
| 541 |
+
"licence_restriction", "sense_index", "upstream_id", "upstream_file",
|
| 542 |
+
"source_variant", "text_withheld"]
|
| 543 |
+
|
| 544 |
+
|
| 545 |
+
def arrow_schema():
|
| 546 |
+
import pyarrow as pa
|
| 547 |
+
|
| 548 |
+
return pa.schema([
|
| 549 |
+
("sl", pa.string()), ("tl", pa.string()), ("id", pa.int64()),
|
| 550 |
+
("src", pa.string()), ("trg", pa.string()), ("entry_type", pa.string()),
|
| 551 |
+
("split", pa.string()), ("source", pa.string()), ("source_url", pa.string()),
|
| 552 |
+
("source_revision", pa.string()), ("licence", pa.string()),
|
| 553 |
+
("licence_tier", pa.int64()), ("redistributable", pa.bool_()),
|
| 554 |
+
("licence_restriction", pa.string()), ("sense_index", pa.int64()),
|
| 555 |
+
("upstream_id", pa.int64()), ("upstream_file", pa.string()),
|
| 556 |
+
("source_variant", pa.string()), ("text_withheld", pa.bool_()),
|
| 557 |
+
])
|
| 558 |
+
|
| 559 |
+
|
| 560 |
+
def write_release(entries, skipped, dropped, selection, rows, release_id=None):
|
| 561 |
+
import pyarrow as pa
|
| 562 |
+
import pyarrow.parquet as pq
|
| 563 |
+
|
| 564 |
+
release_id = release_id or time.strftime("lexicon_%Y%m%dT%H%M%SZ", time.gmtime())
|
| 565 |
+
output = DIST / release_id
|
| 566 |
+
(output / "languages").mkdir(parents=True, exist_ok=True)
|
| 567 |
+
|
| 568 |
+
by_language: dict[str, list[dict]] = {}
|
| 569 |
+
for entry in entries:
|
| 570 |
+
by_language.setdefault(entry["tl"], []).append(entry)
|
| 571 |
+
|
| 572 |
+
flat = []
|
| 573 |
+
languages = {}
|
| 574 |
+
for config in selection["languages"]:
|
| 575 |
+
items = by_language.get(config, [])
|
| 576 |
+
items.sort(key=lambda e: (e["source"], e["sl"], e.get("upstream_id") or 0,
|
| 577 |
+
e.get("sense_index") or 0))
|
| 578 |
+
for index, entry in enumerate(items):
|
| 579 |
+
entry["id"] = index
|
| 580 |
+
path = output / "languages" / f"{config}.jsonl"
|
| 581 |
+
with path.open("w", encoding="utf-8") as handle:
|
| 582 |
+
for entry in items:
|
| 583 |
+
handle.write(json.dumps(entry, ensure_ascii=False) + "\n")
|
| 584 |
+
by_source: dict[str, int] = {}
|
| 585 |
+
by_type: dict[str, int] = {}
|
| 586 |
+
for entry in items:
|
| 587 |
+
by_source[entry["source"]] = by_source.get(entry["source"], 0) + 1
|
| 588 |
+
by_type[entry["entry_type"]] = by_type.get(entry["entry_type"], 0) + 1
|
| 589 |
+
languages[config] = {
|
| 590 |
+
"language_name": selection["languages"][config]["language_name"],
|
| 591 |
+
"iso639_3": selection["languages"][config]["iso639_3"],
|
| 592 |
+
"entries": len(items),
|
| 593 |
+
"redistributable_entries": sum(1 for e in items if e["redistributable"]
|
| 594 |
+
and e["licence_tier"] == TIER_REDISTRIBUTABLE),
|
| 595 |
+
"pivots": sorted({e["sl"] for e in items}),
|
| 596 |
+
"sources": sorted(by_source),
|
| 597 |
+
"by_source": by_source,
|
| 598 |
+
"by_entry_type": by_type,
|
| 599 |
+
}
|
| 600 |
+
flat += items
|
| 601 |
+
|
| 602 |
+
table = pa.Table.from_pylist(
|
| 603 |
+
[{column: entry.get(column) for column in COLUMNS} for entry in flat],
|
| 604 |
+
schema=arrow_schema(),
|
| 605 |
+
)
|
| 606 |
+
pq.write_table(table, output / "lexicon.parquet", compression="zstd")
|
| 607 |
+
|
| 608 |
+
def as_table(items):
|
| 609 |
+
return pa.Table.from_pylist(
|
| 610 |
+
[{column: entry.get(column) for column in COLUMNS} for entry in items],
|
| 611 |
+
schema=arrow_schema(),
|
| 612 |
+
)
|
| 613 |
+
|
| 614 |
+
# Same subset scheme as the other two corpora: everything, plus one per source and
|
| 615 |
+
# language, so a reader can take exactly the lexicon they trust.
|
| 616 |
+
subsets = {"all": list(flat)}
|
| 617 |
+
for source, language in sorted({(e["source"], e["tl"]) for e in flat}):
|
| 618 |
+
subsets[subset_name(source, language)] = [
|
| 619 |
+
e for e in flat if e["source"] == source and e["tl"] == language
|
| 620 |
+
]
|
| 621 |
+
subset_report = write_subsets(output, subsets, as_table, split="lexicon")
|
| 622 |
+
|
| 623 |
+
tiers: dict[str, int] = {}
|
| 624 |
+
for entry in flat:
|
| 625 |
+
tiers[str(entry["licence_tier"])] = tiers.get(str(entry["licence_tier"]), 0) + 1
|
| 626 |
+
|
| 627 |
+
manifest = {
|
| 628 |
+
"release_id": release_id,
|
| 629 |
+
"built_at": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
| 630 |
+
"audit_release": selection["release"],
|
| 631 |
+
"shortlist_count": len(selection["languages"]),
|
| 632 |
+
"total_entries": len(flat),
|
| 633 |
+
"languages_with_entries": sum(1 for v in languages.values() if v["entries"]),
|
| 634 |
+
"languages_without_entries": sorted(
|
| 635 |
+
c for c, v in languages.items() if not v["entries"]
|
| 636 |
+
),
|
| 637 |
+
"entries_by_licence_tier": tiers,
|
| 638 |
+
"licence": "CC-BY-SA-4.0",
|
| 639 |
+
"licence_note": (
|
| 640 |
+
"Share-alike, forced by the CC-BY-SA sources. Per-record 'licence', "
|
| 641 |
+
"'licence_tier' and 'licence_restriction' say what each row actually permits: "
|
| 642 |
+
"tier 1 is freely republishable, tier 2 carries a restriction (non-commercial or "
|
| 643 |
+
"GPL copyleft), tier 3 is counted with the text withheld. Filter on "
|
| 644 |
+
"licence_tier = 1 for a release with no further conditions."
|
| 645 |
+
),
|
| 646 |
+
"entry_types": {
|
| 647 |
+
"word": "a single-word headword and its translation",
|
| 648 |
+
"phrase": "a multiword headword or gloss",
|
| 649 |
+
"example_sentence": "a sentence illustrating a headword, from a dictionary",
|
| 650 |
+
"token_gloss": "one token of a sentence glossed into another language",
|
| 651 |
+
},
|
| 652 |
+
"sources": {
|
| 653 |
+
name: {k: v for k, v in meta.items()} for name, meta in SOURCE_META.items()
|
| 654 |
+
},
|
| 655 |
+
"languages": languages,
|
| 656 |
+
"subsets": subset_report,
|
| 657 |
+
"subset_note": (
|
| 658 |
+
"'all' is every entry. The rest are <source>-<language>: where the entries came "
|
| 659 |
+
"from, and which language they are for."
|
| 660 |
+
),
|
| 661 |
+
"duplicates_collapsed": len(dropped),
|
| 662 |
+
"skipped": skipped,
|
| 663 |
+
"columns": COLUMNS,
|
| 664 |
+
}
|
| 665 |
+
(output / "manifest.json").write_text(
|
| 666 |
+
json.dumps(manifest, ensure_ascii=False, indent=1) + "\n", encoding="utf-8"
|
| 667 |
+
)
|
| 668 |
+
return output, manifest
|
| 669 |
+
|
| 670 |
+
|
| 671 |
+
def build(release_id=None):
|
| 672 |
+
selection = pivots.selection()
|
| 673 |
+
rows = pivots.load_rows(pivots.DIST / selection["release"])
|
| 674 |
+
targets = list(selection["languages"])
|
| 675 |
+
|
| 676 |
+
entries, skipped = [], []
|
| 677 |
+
for label, collector in (
|
| 678 |
+
("chikhapo", lambda: collect_chikhapo(targets, rows)),
|
| 679 |
+
("gatitos", lambda: collect_gatitos(targets, rows)),
|
| 680 |
+
("nusax_lexicon", lambda: collect_nusax_lexicon(targets, rows)),
|
| 681 |
+
("gilaki_top1000", lambda: collect_gilaki_top1000(targets, rows)),
|
| 682 |
+
("apertium", lambda: collect_apertium(targets, rows)),
|
| 683 |
+
("ladin_dizionar", lambda: collect_ladin_dizionar(targets, rows)),
|
| 684 |
+
("divital", lambda: collect_divital(targets, rows)),
|
| 685 |
+
):
|
| 686 |
+
got, missed = collector()
|
| 687 |
+
print(f" {label:<18} {len(got):>8,} entries, {len(missed)} skipped", flush=True)
|
| 688 |
+
entries += got
|
| 689 |
+
skipped += [{"source": label, **entry} for entry in missed]
|
| 690 |
+
|
| 691 |
+
entries, dropped = deduplicate(entries)
|
| 692 |
+
print(f" deduplicated: {len(dropped):,} collapsed -> {len(entries):,} entries")
|
| 693 |
+
output, manifest = write_release(entries, skipped, dropped, selection, rows, release_id)
|
| 694 |
+
print(f"\nrelease: {output}")
|
| 695 |
+
print(f"languages with entries: {manifest['languages_with_entries']}/"
|
| 696 |
+
f"{manifest['shortlist_count']}")
|
| 697 |
+
print(f"entries: {manifest['total_entries']:,} "
|
| 698 |
+
f"by licence tier: {manifest['entries_by_licence_tier']}")
|
| 699 |
+
if manifest["languages_without_entries"]:
|
| 700 |
+
print(f"no lexicon: {manifest['languages_without_entries']}")
|
| 701 |
+
return output, manifest
|
| 702 |
+
|
| 703 |
+
|
| 704 |
+
def main(argv=None) -> int:
|
| 705 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 706 |
+
parser.add_argument("--release-id", default=None)
|
| 707 |
+
args = parser.parse_args(argv)
|
| 708 |
+
build(args.release_id)
|
| 709 |
+
return 0
|
| 710 |
+
|
| 711 |
+
|
| 712 |
+
if __name__ == "__main__":
|
| 713 |
+
raise SystemExit(main())
|
scripts/publish_corpus.py
CHANGED
|
@@ -45,6 +45,15 @@ TARGETS = {
|
|
| 45 |
"pretty": "Existing parallel training data for under-served languages",
|
| 46 |
"tags": ["machine-translation", "parallel-corpus", "low-resource", "baseline"],
|
| 47 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
}
|
| 49 |
|
| 50 |
|
|
@@ -103,6 +112,124 @@ def subset_table(manifest: dict, limit: int = 30) -> str:
|
|
| 103 |
return rows, len(pairs)
|
| 104 |
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
def eval_card(manifest: dict, target: dict) -> str:
|
| 107 |
pair_rows, pair_count = subset_table(manifest)
|
| 108 |
languages = manifest["languages"]
|
|
@@ -362,7 +489,8 @@ Built from audit release `{manifest['audit_release']}` and evaluation release
|
|
| 362 |
def stage(release: Path, target: dict, kind: str) -> dict:
|
| 363 |
"""Lay out the files to upload and the card, without touching the release directory."""
|
| 364 |
manifest = json.loads((release / "manifest.json").read_text(encoding="utf-8"))
|
| 365 |
-
card =
|
|
|
|
| 366 |
uploads = {
|
| 367 |
f"data/{target['parquet']}": release / target["parquet"],
|
| 368 |
"manifest.json": release / "manifest.json",
|
|
@@ -403,7 +531,9 @@ def publish(kind: str, release: Path | None = None, dry_run: bool = False) -> di
|
|
| 403 |
"dataset_id": target["dataset_id"],
|
| 404 |
"files": len(staged["uploads"]) + 1,
|
| 405 |
"rows": rows,
|
| 406 |
-
"records"
|
|
|
|
|
|
|
| 407 |
"bytes": sum(p.stat().st_size for p in staged["uploads"].values()),
|
| 408 |
"checksums": {name: _sha256(path)[:16] for name, path in staged["uploads"].items()},
|
| 409 |
}
|
|
|
|
| 45 |
"pretty": "Existing parallel training data for under-served languages",
|
| 46 |
"tags": ["machine-translation", "parallel-corpus", "low-resource", "baseline"],
|
| 47 |
},
|
| 48 |
+
"lexicon": {
|
| 49 |
+
"dataset_id": "sigiranic/underserved-translation-lexicons",
|
| 50 |
+
"root": ROOT / "dist" / "lexicon_corpus",
|
| 51 |
+
"glob": "lexicon_*",
|
| 52 |
+
"parquet": "lexicon.parquet",
|
| 53 |
+
"split": "lexicon",
|
| 54 |
+
"pretty": "Lexicons, glossaries and glosses for under-served languages",
|
| 55 |
+
"tags": ["machine-translation", "lexicon", "low-resource", "bilingual-dictionary"],
|
| 56 |
+
},
|
| 57 |
}
|
| 58 |
|
| 59 |
|
|
|
|
| 112 |
return rows, len(pairs)
|
| 113 |
|
| 114 |
|
| 115 |
+
def lexicon_card(manifest: dict, target: dict) -> str:
|
| 116 |
+
subset_rows, subset_count = subset_table(manifest)
|
| 117 |
+
languages = manifest["languages"]
|
| 118 |
+
ranked = sorted(languages.items(), key=lambda kv: -kv[1]["entries"])
|
| 119 |
+
rows = "\n".join(
|
| 120 |
+
f"| `{config}` | {entry['language_name']} | {entry['entries']:,} | "
|
| 121 |
+
f"{entry['redistributable_entries']:,} | {', '.join(entry['pivots'])} | "
|
| 122 |
+
f"{', '.join(entry['sources'])} |"
|
| 123 |
+
for config, entry in ranked
|
| 124 |
+
)
|
| 125 |
+
sources = "\n".join(
|
| 126 |
+
f"| [{name}]({meta['url']}) | `{str(meta['revision'])[:12]}` | {meta['licence']} | "
|
| 127 |
+
f"tier {meta['tier']} | {meta['note']} |"
|
| 128 |
+
for name, meta in sorted(manifest["sources"].items())
|
| 129 |
+
)
|
| 130 |
+
types = "\n".join(
|
| 131 |
+
f"| `{name}` | {description} |"
|
| 132 |
+
for name, description in manifest["entry_types"].items()
|
| 133 |
+
)
|
| 134 |
+
tiers = manifest["entries_by_licence_tier"]
|
| 135 |
+
return f"""---
|
| 136 |
+
license: cc-by-sa-4.0
|
| 137 |
+
task_categories:
|
| 138 |
+
- translation
|
| 139 |
+
pretty_name: {target['pretty']}
|
| 140 |
+
size_categories:
|
| 141 |
+
- 100K<n<1M
|
| 142 |
+
tags:
|
| 143 |
+
{chr(10).join(f'- {tag}' for tag in target['tags'])}
|
| 144 |
+
{config_block(manifest)}
|
| 145 |
+
---
|
| 146 |
+
|
| 147 |
+
# {target['pretty']}
|
| 148 |
+
|
| 149 |
+
Bilingual dictionaries, parallel wordlists, dictionary example sentences and token-level
|
| 150 |
+
glosses for the {manifest['shortlist_count']} languages shortlisted by
|
| 151 |
+
[sigiranic/language-status](https://huggingface.co/datasets/sigiranic/language-status).
|
| 152 |
+
|
| 153 |
+
For several of these languages this is the only human-curated translation evidence that
|
| 154 |
+
exists. It is the material a system can be seeded from when there is almost no parallel text
|
| 155 |
+
to train on, and it is deliberately kept separate from the two sentence-level corpora:
|
| 156 |
+
|
| 157 |
+
- [sigiranic/underserved-translation-eval](https://huggingface.co/datasets/sigiranic/underserved-translation-eval) — human test sets
|
| 158 |
+
- [sigiranic/underserved-translation-baseline](https://huggingface.co/datasets/sigiranic/underserved-translation-baseline) — existing training data
|
| 159 |
+
|
| 160 |
+
**{manifest['total_entries']:,} entries** across {manifest['languages_with_entries']} of
|
| 161 |
+
{manifest['shortlist_count']} languages.
|
| 162 |
+
|
| 163 |
+
## What a row is
|
| 164 |
+
|
| 165 |
+
Rows use the same `sl`/`tl`/`src`/`trg` shape as the other two corpora, so one reader handles
|
| 166 |
+
all three. `entry_type` says what the row actually is, because these are not interchangeable
|
| 167 |
+
kinds of evidence:
|
| 168 |
+
|
| 169 |
+
| `entry_type` | meaning |
|
| 170 |
+
|---|---|
|
| 171 |
+
{types}
|
| 172 |
+
|
| 173 |
+
## Licence tiers
|
| 174 |
+
|
| 175 |
+
{manifest['licence_note']}
|
| 176 |
+
|
| 177 |
+
| tier | entries |
|
| 178 |
+
|---|--:|
|
| 179 |
+
| 1 — freely republishable | {tiers.get('1', 0):,} |
|
| 180 |
+
| 2 — republishable with a restriction | {tiers.get('2', 0):,} |
|
| 181 |
+
| 3 — counted, text withheld | {tiers.get('3', 0):,} |
|
| 182 |
+
|
| 183 |
+
```python
|
| 184 |
+
from datasets import load_dataset
|
| 185 |
+
|
| 186 |
+
# Everything.
|
| 187 |
+
lex = load_dataset("{target['dataset_id']}", "all", split="lexicon")
|
| 188 |
+
|
| 189 |
+
# Only entries with no further conditions attached.
|
| 190 |
+
free = lex.filter(lambda row: row["licence_tier"] == 1)
|
| 191 |
+
|
| 192 |
+
# Only real sentences, not headwords.
|
| 193 |
+
examples = lex.filter(lambda row: row["entry_type"] == "example_sentence")
|
| 194 |
+
```
|
| 195 |
+
|
| 196 |
+
## Languages
|
| 197 |
+
|
| 198 |
+
| config | language | entries | tier 1 | pivots | sources |
|
| 199 |
+
|---|---|--:|--:|---|---|
|
| 200 |
+
{rows}
|
| 201 |
+
|
| 202 |
+
## Sources
|
| 203 |
+
|
| 204 |
+
| source | revision | licence | tier | what it is |
|
| 205 |
+
|---|---|---|---|---|
|
| 206 |
+
{sources}
|
| 207 |
+
|
| 208 |
+
## Subsets
|
| 209 |
+
|
| 210 |
+
`all` is every entry. The other {subset_count} are `<source>-<language>`: where the entries
|
| 211 |
+
came from, and which language they are for.
|
| 212 |
+
|
| 213 |
+
| subset | entries | splits |
|
| 214 |
+
|---|--:|---|
|
| 215 |
+
{subset_rows}
|
| 216 |
+
|
| 217 |
+
## Caveats
|
| 218 |
+
|
| 219 |
+
- A dictionary headword is not a sentence. Training on `word` rows teaches vocabulary, not
|
| 220 |
+
syntax; only the `example_sentence` and `token_gloss` rows carry structure.
|
| 221 |
+
- Many entries reach this release through PanLex, so ChiKhaPo, GATITOS and Apertium overlap.
|
| 222 |
+
Duplicates are collapsed on the normalised pair, keeping the most freely licensed copy.
|
| 223 |
+
- Entry counts are not quality. A language with thousands of entries from one aggregated
|
| 224 |
+
source may have had less human curation than one with a few hundred hand-written ones.
|
| 225 |
+
- Gilaki is absent from ChiKhaPo entirely, so its entries come from a single GPL-3.0 source.
|
| 226 |
+
That makes it the one language here with no tier-1 lexicon at all.
|
| 227 |
+
|
| 228 |
+
Built by `scripts/build_lexicon_corpus.py`; release `{manifest['release_id']}`, derived from
|
| 229 |
+
audit release `{manifest['audit_release']}`.
|
| 230 |
+
"""
|
| 231 |
+
|
| 232 |
+
|
| 233 |
def eval_card(manifest: dict, target: dict) -> str:
|
| 234 |
pair_rows, pair_count = subset_table(manifest)
|
| 235 |
languages = manifest["languages"]
|
|
|
|
| 489 |
def stage(release: Path, target: dict, kind: str) -> dict:
|
| 490 |
"""Lay out the files to upload and the card, without touching the release directory."""
|
| 491 |
manifest = json.loads((release / "manifest.json").read_text(encoding="utf-8"))
|
| 492 |
+
card = {"eval": eval_card, "baseline": baseline_card,
|
| 493 |
+
"lexicon": lexicon_card}[kind](manifest, target)
|
| 494 |
uploads = {
|
| 495 |
f"data/{target['parquet']}": release / target["parquet"],
|
| 496 |
"manifest.json": release / "manifest.json",
|
|
|
|
| 531 |
"dataset_id": target["dataset_id"],
|
| 532 |
"files": len(staged["uploads"]) + 1,
|
| 533 |
"rows": rows,
|
| 534 |
+
# The sentence corpora count "records"; the lexicon counts "entries".
|
| 535 |
+
"records": staged["manifest"].get("total_records")
|
| 536 |
+
or staged["manifest"]["total_entries"],
|
| 537 |
"bytes": sum(p.stat().st_size for p in staged["uploads"].values()),
|
| 538 |
"checksums": {name: _sha256(path)[:16] for name, path in staged["uploads"].items()},
|
| 539 |
}
|
scripts/stage_audit_extras.py
CHANGED
|
@@ -51,6 +51,8 @@ PIPELINE = [
|
|
| 51 |
"Gathers the human-written test sets for the shortlist into the evaluation dataset."),
|
| 52 |
("scripts/build_baseline_corpus.py",
|
| 53 |
"Downloads the existing OPUS and Tatoeba training data as the comparison baseline."),
|
|
|
|
|
|
|
| 54 |
("scripts/corpus_subsets.py",
|
| 55 |
"Shared subset writer used by both corpus builders (<source>-<language> configs)."),
|
| 56 |
("scripts/stage_audit_extras.py",
|
|
@@ -69,7 +71,9 @@ SUPPORTING = [
|
|
| 69 |
("tests/test_lang_audit.py",
|
| 70 |
"Tests for the audit: code resolution, prefix collisions, thresholds, derived columns."),
|
| 71 |
("tests/test_eval_corpus.py",
|
| 72 |
-
"Tests for
|
|
|
|
|
|
|
| 73 |
]
|
| 74 |
|
| 75 |
TEST_COMMAND = ".venv-publish/bin/python -m unittest discover -s tests -q"
|
|
@@ -77,6 +81,7 @@ TEST_COMMAND = ".venv-publish/bin/python -m unittest discover -s tests -q"
|
|
| 77 |
# Where the companion datasets live, so the published list is navigable.
|
| 78 |
EVAL_DATASET = "sigiranic/underserved-translation-eval"
|
| 79 |
BASELINE_DATASET = "sigiranic/underserved-translation-baseline"
|
|
|
|
| 80 |
|
| 81 |
|
| 82 |
def _sha256(path: Path) -> str:
|
|
@@ -108,15 +113,18 @@ def selected_languages(release: Path) -> dict:
|
|
| 108 |
selection = shortlist_pivots.selection(release)
|
| 109 |
evaluation = _corpus_manifest("eval_corpus/eval_*")
|
| 110 |
baseline = _corpus_manifest("baseline_corpus/baseline_*")
|
|
|
|
| 111 |
|
| 112 |
eval_langs = evaluation.get("languages", {})
|
| 113 |
base_langs = baseline.get("languages", {})
|
|
|
|
| 114 |
|
| 115 |
languages = []
|
| 116 |
for config, entry in selection["languages"].items():
|
| 117 |
row = rows[config]
|
| 118 |
got = eval_langs.get(config, {})
|
| 119 |
had = base_langs.get(config, {})
|
|
|
|
| 120 |
languages.append({
|
| 121 |
"finewiki_config": config,
|
| 122 |
"iso639_3": entry["iso639_3"],
|
|
@@ -141,6 +149,12 @@ def selected_languages(release: Path) -> dict:
|
|
| 141 |
"sources": got.get("sources", []),
|
| 142 |
"by_source": got.get("by_source", {}),
|
| 143 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
"baseline": {
|
| 145 |
"records": had.get("records", 0),
|
| 146 |
"human_records": had.get("human_records", 0),
|
|
@@ -164,6 +178,8 @@ def selected_languages(release: Path) -> dict:
|
|
| 164 |
"baseline_release": baseline.get("release_id"),
|
| 165 |
"evaluation_dataset": EVAL_DATASET,
|
| 166 |
"baseline_dataset": BASELINE_DATASET,
|
|
|
|
|
|
|
| 167 |
"count": len(languages),
|
| 168 |
"with_evaluation_data": sum(1 for entry in languages if entry["evaluation"]["records"]),
|
| 169 |
"without_any_test_data": without,
|
|
@@ -183,8 +199,9 @@ def selected_languages_markdown(data: dict) -> str:
|
|
| 183 |
f"{data['count']} languages, {data['with_evaluation_data']} of them with "
|
| 184 |
"evaluation data.",
|
| 185 |
"",
|
| 186 |
-
"| # | config | ISO | language | family | articles | pivots | eval |
|
| 187 |
-
"|
|
|
|
|
| 188 |
]
|
| 189 |
for entry in data["languages"]:
|
| 190 |
lines.append(
|
|
@@ -193,6 +210,7 @@ def selected_languages_markdown(data: dict) -> str:
|
|
| 193 |
f"| {entry['family_name'] or '—'} | {entry['finewiki_articles']:,} "
|
| 194 |
f"| {', '.join(f'`{code}`' for code in entry['pivots'])} "
|
| 195 |
f"| {entry['evaluation']['records']:,} "
|
|
|
|
| 196 |
f"| {entry['baseline']['records']:,} "
|
| 197 |
f"| {entry['baseline']['human_records']:,} |"
|
| 198 |
)
|
|
@@ -206,7 +224,7 @@ def selected_languages_markdown(data: dict) -> str:
|
|
| 206 |
]
|
| 207 |
lines += [
|
| 208 |
"",
|
| 209 |
-
"`eval` and `baseline` are
|
| 210 |
f"[{data['evaluation_dataset']}](https://huggingface.co/datasets/{data['evaluation_dataset']}) "
|
| 211 |
f"and [{data['baseline_dataset']}](https://huggingface.co/datasets/{data['baseline_dataset']}). "
|
| 212 |
"`human baseline` is the part of the baseline written by people rather than "
|
|
|
|
| 51 |
"Gathers the human-written test sets for the shortlist into the evaluation dataset."),
|
| 52 |
("scripts/build_baseline_corpus.py",
|
| 53 |
"Downloads the existing OPUS and Tatoeba training data as the comparison baseline."),
|
| 54 |
+
("scripts/build_lexicon_corpus.py",
|
| 55 |
+
"Gathers bilingual dictionaries, wordlists and token glosses into the lexicon dataset."),
|
| 56 |
("scripts/corpus_subsets.py",
|
| 57 |
"Shared subset writer used by both corpus builders (<source>-<language> configs)."),
|
| 58 |
("scripts/stage_audit_extras.py",
|
|
|
|
| 71 |
("tests/test_lang_audit.py",
|
| 72 |
"Tests for the audit: code resolution, prefix collisions, thresholds, derived columns."),
|
| 73 |
("tests/test_eval_corpus.py",
|
| 74 |
+
"Tests for the sentence corpora: parsing, pivots, de-duplication, contamination."),
|
| 75 |
+
("tests/test_lexicon_corpus.py",
|
| 76 |
+
"Tests for the lexicon corpus and the licence tiering both corpora share."),
|
| 77 |
]
|
| 78 |
|
| 79 |
TEST_COMMAND = ".venv-publish/bin/python -m unittest discover -s tests -q"
|
|
|
|
| 81 |
# Where the companion datasets live, so the published list is navigable.
|
| 82 |
EVAL_DATASET = "sigiranic/underserved-translation-eval"
|
| 83 |
BASELINE_DATASET = "sigiranic/underserved-translation-baseline"
|
| 84 |
+
LEXICON_DATASET = "sigiranic/underserved-translation-lexicons"
|
| 85 |
|
| 86 |
|
| 87 |
def _sha256(path: Path) -> str:
|
|
|
|
| 113 |
selection = shortlist_pivots.selection(release)
|
| 114 |
evaluation = _corpus_manifest("eval_corpus/eval_*")
|
| 115 |
baseline = _corpus_manifest("baseline_corpus/baseline_*")
|
| 116 |
+
lexicon = _corpus_manifest("lexicon_corpus/lexicon_*")
|
| 117 |
|
| 118 |
eval_langs = evaluation.get("languages", {})
|
| 119 |
base_langs = baseline.get("languages", {})
|
| 120 |
+
lex_langs = lexicon.get("languages", {})
|
| 121 |
|
| 122 |
languages = []
|
| 123 |
for config, entry in selection["languages"].items():
|
| 124 |
row = rows[config]
|
| 125 |
got = eval_langs.get(config, {})
|
| 126 |
had = base_langs.get(config, {})
|
| 127 |
+
words = lex_langs.get(config, {})
|
| 128 |
languages.append({
|
| 129 |
"finewiki_config": config,
|
| 130 |
"iso639_3": entry["iso639_3"],
|
|
|
|
| 149 |
"sources": got.get("sources", []),
|
| 150 |
"by_source": got.get("by_source", {}),
|
| 151 |
},
|
| 152 |
+
"lexicon": {
|
| 153 |
+
"entries": words.get("entries", 0),
|
| 154 |
+
"redistributable_entries": words.get("redistributable_entries", 0),
|
| 155 |
+
"sources": words.get("sources", []),
|
| 156 |
+
"by_entry_type": words.get("by_entry_type", {}),
|
| 157 |
+
},
|
| 158 |
"baseline": {
|
| 159 |
"records": had.get("records", 0),
|
| 160 |
"human_records": had.get("human_records", 0),
|
|
|
|
| 178 |
"baseline_release": baseline.get("release_id"),
|
| 179 |
"evaluation_dataset": EVAL_DATASET,
|
| 180 |
"baseline_dataset": BASELINE_DATASET,
|
| 181 |
+
"lexicon_dataset": LEXICON_DATASET,
|
| 182 |
+
"lexicon_release": lexicon.get("release_id"),
|
| 183 |
"count": len(languages),
|
| 184 |
"with_evaluation_data": sum(1 for entry in languages if entry["evaluation"]["records"]),
|
| 185 |
"without_any_test_data": without,
|
|
|
|
| 199 |
f"{data['count']} languages, {data['with_evaluation_data']} of them with "
|
| 200 |
"evaluation data.",
|
| 201 |
"",
|
| 202 |
+
"| # | config | ISO | language | family | articles | pivots | eval | lexicon | "
|
| 203 |
+
"baseline | human baseline |",
|
| 204 |
+
"|--:|---|---|---|---|--:|---|--:|--:|--:|--:|",
|
| 205 |
]
|
| 206 |
for entry in data["languages"]:
|
| 207 |
lines.append(
|
|
|
|
| 210 |
f"| {entry['family_name'] or '—'} | {entry['finewiki_articles']:,} "
|
| 211 |
f"| {', '.join(f'`{code}`' for code in entry['pivots'])} "
|
| 212 |
f"| {entry['evaluation']['records']:,} "
|
| 213 |
+
f"| {entry['lexicon']['entries']:,} "
|
| 214 |
f"| {entry['baseline']['records']:,} "
|
| 215 |
f"| {entry['baseline']['human_records']:,} |"
|
| 216 |
)
|
|
|
|
| 224 |
]
|
| 225 |
lines += [
|
| 226 |
"",
|
| 227 |
+
"`eval`, `lexicon` and `baseline` are counts in "
|
| 228 |
f"[{data['evaluation_dataset']}](https://huggingface.co/datasets/{data['evaluation_dataset']}) "
|
| 229 |
f"and [{data['baseline_dataset']}](https://huggingface.co/datasets/{data['baseline_dataset']}). "
|
| 230 |
"`human baseline` is the part of the baseline written by people rather than "
|
selected_languages.json
CHANGED
|
@@ -1,19 +1,15 @@
|
|
| 1 |
{
|
| 2 |
"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.",
|
| 3 |
"audit_release": "finewiki_audit_20261114T182048Z",
|
| 4 |
-
"evaluation_release": "
|
| 5 |
-
"baseline_release": "
|
| 6 |
"evaluation_dataset": "sigiranic/underserved-translation-eval",
|
| 7 |
"baseline_dataset": "sigiranic/underserved-translation-baseline",
|
|
|
|
|
|
|
| 8 |
"count": 22,
|
| 9 |
-
"with_evaluation_data":
|
| 10 |
-
"without_any_test_data": [
|
| 11 |
-
"azb",
|
| 12 |
-
"bug",
|
| 13 |
-
"dag",
|
| 14 |
-
"skr",
|
| 15 |
-
"wuu"
|
| 16 |
-
],
|
| 17 |
"pivot_rule": "The audit's shortlist languages and the pivot languages worth pairing each one with.",
|
| 18 |
"languages": [
|
| 19 |
{
|
|
@@ -65,6 +61,20 @@
|
|
| 65 |
"xsid": 1389
|
| 66 |
}
|
| 67 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
"baseline": {
|
| 69 |
"records": 182,
|
| 70 |
"human_records": 4,
|
|
@@ -119,16 +129,31 @@
|
|
| 119 |
]
|
| 120 |
},
|
| 121 |
"evaluation": {
|
| 122 |
-
"records":
|
| 123 |
-
"test":
|
| 124 |
"dev": 0,
|
| 125 |
"sources": [
|
|
|
|
| 126 |
"tatoeba_challenge"
|
| 127 |
],
|
| 128 |
"by_source": {
|
|
|
|
| 129 |
"tatoeba_challenge": 56
|
| 130 |
}
|
| 131 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
"baseline": {
|
| 133 |
"records": 4431,
|
| 134 |
"human_records": 107,
|
|
@@ -179,14 +204,29 @@
|
|
| 179 |
]
|
| 180 |
},
|
| 181 |
"evaluation": {
|
| 182 |
-
"records":
|
| 183 |
-
"test":
|
| 184 |
-
"dev":
|
| 185 |
-
"sources": [
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
},
|
| 188 |
"baseline": {
|
| 189 |
-
"records":
|
| 190 |
"human_records": 0,
|
| 191 |
"human_share": 0.0,
|
| 192 |
"corpora": [
|
|
@@ -195,7 +235,7 @@
|
|
| 195 |
],
|
| 196 |
"by_corpus_type": {
|
| 197 |
"ui_strings": 7004,
|
| 198 |
-
"auto_mined":
|
| 199 |
}
|
| 200 |
}
|
| 201 |
},
|
|
@@ -244,6 +284,18 @@
|
|
| 244 |
"tatoeba_challenge": 39
|
| 245 |
}
|
| 246 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
"baseline": {
|
| 248 |
"records": 2894,
|
| 249 |
"human_records": 0,
|
|
@@ -295,20 +347,33 @@
|
|
| 295 |
]
|
| 296 |
},
|
| 297 |
"evaluation": {
|
| 298 |
-
"records":
|
| 299 |
-
"test":
|
| 300 |
"dev": 2000,
|
| 301 |
"sources": [
|
|
|
|
| 302 |
"parme",
|
| 303 |
"smol"
|
| 304 |
],
|
| 305 |
"by_source": {
|
|
|
|
| 306 |
"parme": 4000,
|
| 307 |
"smol": 863
|
| 308 |
}
|
| 309 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 310 |
"baseline": {
|
| 311 |
-
"records":
|
| 312 |
"human_records": 0,
|
| 313 |
"human_share": 0.0,
|
| 314 |
"corpora": [
|
|
@@ -316,7 +381,7 @@
|
|
| 316 |
"wikimedia"
|
| 317 |
],
|
| 318 |
"by_corpus_type": {
|
| 319 |
-
"ui_strings":
|
| 320 |
"auto_mined": 694
|
| 321 |
}
|
| 322 |
}
|
|
@@ -361,16 +426,30 @@
|
|
| 361 |
]
|
| 362 |
},
|
| 363 |
"evaluation": {
|
| 364 |
-
"records":
|
| 365 |
-
"test":
|
| 366 |
"dev": 0,
|
| 367 |
"sources": [
|
|
|
|
| 368 |
"tatoeba_challenge"
|
| 369 |
],
|
| 370 |
"by_source": {
|
|
|
|
| 371 |
"tatoeba_challenge": 754
|
| 372 |
}
|
| 373 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
"baseline": {
|
| 375 |
"records": 23625,
|
| 376 |
"human_records": 0,
|
|
@@ -419,6 +498,18 @@
|
|
| 419 |
"tatoeba_challenge": 3388
|
| 420 |
}
|
| 421 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 422 |
"baseline": {
|
| 423 |
"records": 7294,
|
| 424 |
"human_records": 2217,
|
|
@@ -471,18 +562,32 @@
|
|
| 471 |
]
|
| 472 |
},
|
| 473 |
"evaluation": {
|
| 474 |
-
"records":
|
| 475 |
-
"test":
|
| 476 |
"dev": 245,
|
| 477 |
"sources": [
|
|
|
|
| 478 |
"tatoeba_challenge",
|
| 479 |
"xsid"
|
| 480 |
],
|
| 481 |
"by_source": {
|
|
|
|
| 482 |
"tatoeba_challenge": 2,
|
| 483 |
"xsid": 693
|
| 484 |
}
|
| 485 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 486 |
"baseline": {
|
| 487 |
"records": 11342,
|
| 488 |
"human_records": 31,
|
|
@@ -548,6 +653,18 @@
|
|
| 548 |
"parme": 4000
|
| 549 |
}
|
| 550 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 551 |
"baseline": {
|
| 552 |
"records": 5654,
|
| 553 |
"human_records": 0,
|
|
@@ -605,18 +722,31 @@
|
|
| 605 |
]
|
| 606 |
},
|
| 607 |
"evaluation": {
|
| 608 |
-
"records":
|
| 609 |
-
"test":
|
| 610 |
"dev": 0,
|
| 611 |
"sources": [
|
|
|
|
| 612 |
"tatoeba_challenge"
|
| 613 |
],
|
| 614 |
"by_source": {
|
|
|
|
| 615 |
"tatoeba_challenge": 395
|
| 616 |
}
|
| 617 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 618 |
"baseline": {
|
| 619 |
-
"records":
|
| 620 |
"human_records": 0,
|
| 621 |
"human_share": 0.0,
|
| 622 |
"corpora": [
|
|
@@ -625,7 +755,7 @@
|
|
| 625 |
],
|
| 626 |
"by_corpus_type": {
|
| 627 |
"auto_mined": 550,
|
| 628 |
-
"ui_strings":
|
| 629 |
}
|
| 630 |
}
|
| 631 |
},
|
|
@@ -662,6 +792,17 @@
|
|
| 662 |
"tatoeba_challenge": 2077
|
| 663 |
}
|
| 664 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 665 |
"baseline": {
|
| 666 |
"records": 2100,
|
| 667 |
"human_records": 48,
|
|
@@ -711,20 +852,34 @@
|
|
| 711 |
]
|
| 712 |
},
|
| 713 |
"evaluation": {
|
| 714 |
-
"records":
|
| 715 |
-
"test":
|
| 716 |
"dev": 1073,
|
| 717 |
"sources": [
|
|
|
|
| 718 |
"nalibasid",
|
| 719 |
"tatoeba_challenge",
|
| 720 |
"xsid"
|
| 721 |
],
|
| 722 |
"by_source": {
|
|
|
|
| 723 |
"nalibasid": 2722,
|
| 724 |
"tatoeba_challenge": 216,
|
| 725 |
"xsid": 2
|
| 726 |
}
|
| 727 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 728 |
"baseline": {
|
| 729 |
"records": 268537,
|
| 730 |
"human_records": 40,
|
|
@@ -784,6 +939,17 @@
|
|
| 784 |
"tatoeba_challenge": 506
|
| 785 |
}
|
| 786 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 787 |
"baseline": {
|
| 788 |
"records": 4786,
|
| 789 |
"human_records": 124,
|
|
@@ -842,6 +1008,19 @@
|
|
| 842 |
"tatoeba_challenge": 143
|
| 843 |
}
|
| 844 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 845 |
"baseline": {
|
| 846 |
"records": 25457,
|
| 847 |
"human_records": 3158,
|
|
@@ -889,15 +1068,30 @@
|
|
| 889 |
]
|
| 890 |
},
|
| 891 |
"evaluation": {
|
| 892 |
-
"records":
|
| 893 |
-
"test":
|
| 894 |
-
"dev":
|
| 895 |
-
"sources": [
|
| 896 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 897 |
},
|
| 898 |
"baseline": {
|
| 899 |
-
"records":
|
| 900 |
-
"human_records":
|
| 901 |
"human_share": 0.0111,
|
| 902 |
"corpora": [
|
| 903 |
"Tatoeba",
|
|
@@ -909,7 +1103,7 @@
|
|
| 909 |
"by_corpus_type": {
|
| 910 |
"auto_mined": 65202,
|
| 911 |
"entity_list": 33086,
|
| 912 |
-
"crowd_sentences":
|
| 913 |
"ui_strings": 11
|
| 914 |
}
|
| 915 |
}
|
|
@@ -947,6 +1141,18 @@
|
|
| 947 |
"tatoeba_challenge": 5368
|
| 948 |
}
|
| 949 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 950 |
"baseline": {
|
| 951 |
"records": 24065,
|
| 952 |
"human_records": 18157,
|
|
@@ -990,14 +1196,27 @@
|
|
| 990 |
]
|
| 991 |
},
|
| 992 |
"evaluation": {
|
| 993 |
-
"records":
|
| 994 |
-
"test":
|
| 995 |
"dev": 0,
|
| 996 |
"sources": [
|
| 997 |
-
"tatoeba_challenge"
|
|
|
|
| 998 |
],
|
| 999 |
"by_source": {
|
| 1000 |
-
"tatoeba_challenge": 79
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1001 |
}
|
| 1002 |
},
|
| 1003 |
"baseline": {
|
|
@@ -1049,6 +1268,19 @@
|
|
| 1049 |
"tatoeba_challenge": 19292
|
| 1050 |
}
|
| 1051 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1052 |
"baseline": {
|
| 1053 |
"records": 225567,
|
| 1054 |
"human_records": 30146,
|
|
@@ -1105,16 +1337,35 @@
|
|
| 1105 |
]
|
| 1106 |
},
|
| 1107 |
"evaluation": {
|
| 1108 |
-
"records":
|
| 1109 |
-
"test":
|
| 1110 |
-
"dev":
|
| 1111 |
-
"sources": [
|
| 1112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1113 |
},
|
| 1114 |
"baseline": {
|
| 1115 |
-
"records":
|
| 1116 |
"human_records": 1489,
|
| 1117 |
-
"human_share": 0.
|
| 1118 |
"corpora": [
|
| 1119 |
"NLLB",
|
| 1120 |
"QED",
|
|
@@ -1122,7 +1373,7 @@
|
|
| 1122 |
"wikimedia"
|
| 1123 |
],
|
| 1124 |
"by_corpus_type": {
|
| 1125 |
-
"auto_mined":
|
| 1126 |
"subtitles": 1489,
|
| 1127 |
"ui_strings": 558
|
| 1128 |
}
|
|
@@ -1158,11 +1409,26 @@
|
|
| 1158 |
]
|
| 1159 |
},
|
| 1160 |
"evaluation": {
|
| 1161 |
-
"records":
|
| 1162 |
-
"test":
|
| 1163 |
"dev": 0,
|
| 1164 |
-
"sources": [
|
| 1165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1166 |
},
|
| 1167 |
"baseline": {
|
| 1168 |
"records": 7706,
|
|
@@ -1208,6 +1474,18 @@
|
|
| 1208 |
"tatoeba_challenge": 80
|
| 1209 |
}
|
| 1210 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1211 |
"baseline": {
|
| 1212 |
"records": 357,
|
| 1213 |
"human_records": 28,
|
|
@@ -1261,11 +1539,27 @@
|
|
| 1261 |
]
|
| 1262 |
},
|
| 1263 |
"evaluation": {
|
| 1264 |
-
"records":
|
| 1265 |
-
"test":
|
| 1266 |
-
"dev":
|
| 1267 |
-
"sources": [
|
| 1268 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1269 |
},
|
| 1270 |
"baseline": {
|
| 1271 |
"records": 24777,
|
|
|
|
| 1 |
{
|
| 2 |
"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.",
|
| 3 |
"audit_release": "finewiki_audit_20261114T182048Z",
|
| 4 |
+
"evaluation_release": "eval_20261114T230126Z",
|
| 5 |
+
"baseline_release": "baseline_20261114T230143Z",
|
| 6 |
"evaluation_dataset": "sigiranic/underserved-translation-eval",
|
| 7 |
"baseline_dataset": "sigiranic/underserved-translation-baseline",
|
| 8 |
+
"lexicon_dataset": "sigiranic/underserved-translation-lexicons",
|
| 9 |
+
"lexicon_release": "lexicon_20261114T225919Z",
|
| 10 |
"count": 22,
|
| 11 |
+
"with_evaluation_data": 22,
|
| 12 |
+
"without_any_test_data": [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
"pivot_rule": "The audit's shortlist languages and the pivot languages worth pairing each one with.",
|
| 14 |
"languages": [
|
| 15 |
{
|
|
|
|
| 61 |
"xsid": 1389
|
| 62 |
}
|
| 63 |
},
|
| 64 |
+
"lexicon": {
|
| 65 |
+
"entries": 10973,
|
| 66 |
+
"redistributable_entries": 10973,
|
| 67 |
+
"sources": [
|
| 68 |
+
"chikhapo",
|
| 69 |
+
"divital"
|
| 70 |
+
],
|
| 71 |
+
"by_entry_type": {
|
| 72 |
+
"word": 3327,
|
| 73 |
+
"phrase": 1316,
|
| 74 |
+
"example_sentence": 31,
|
| 75 |
+
"token_gloss": 6299
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
"baseline": {
|
| 79 |
"records": 182,
|
| 80 |
"human_records": 4,
|
|
|
|
| 129 |
]
|
| 130 |
},
|
| 131 |
"evaluation": {
|
| 132 |
+
"records": 436,
|
| 133 |
+
"test": 436,
|
| 134 |
"dev": 0,
|
| 135 |
"sources": [
|
| 136 |
+
"codet",
|
| 137 |
"tatoeba_challenge"
|
| 138 |
],
|
| 139 |
"by_source": {
|
| 140 |
+
"codet": 380,
|
| 141 |
"tatoeba_challenge": 56
|
| 142 |
}
|
| 143 |
},
|
| 144 |
+
"lexicon": {
|
| 145 |
+
"entries": 53113,
|
| 146 |
+
"redistributable_entries": 1361,
|
| 147 |
+
"sources": [
|
| 148 |
+
"chikhapo",
|
| 149 |
+
"ladin_dizionar"
|
| 150 |
+
],
|
| 151 |
+
"by_entry_type": {
|
| 152 |
+
"phrase": 40107,
|
| 153 |
+
"word": 1278,
|
| 154 |
+
"example_sentence": 11728
|
| 155 |
+
}
|
| 156 |
+
},
|
| 157 |
"baseline": {
|
| 158 |
"records": 4431,
|
| 159 |
"human_records": 107,
|
|
|
|
| 204 |
]
|
| 205 |
},
|
| 206 |
"evaluation": {
|
| 207 |
+
"records": 3348,
|
| 208 |
+
"test": 2102,
|
| 209 |
+
"dev": 1246,
|
| 210 |
+
"sources": [
|
| 211 |
+
"bouquet"
|
| 212 |
+
],
|
| 213 |
+
"by_source": {
|
| 214 |
+
"bouquet": 3348
|
| 215 |
+
}
|
| 216 |
+
},
|
| 217 |
+
"lexicon": {
|
| 218 |
+
"entries": 853,
|
| 219 |
+
"redistributable_entries": 853,
|
| 220 |
+
"sources": [
|
| 221 |
+
"chikhapo"
|
| 222 |
+
],
|
| 223 |
+
"by_entry_type": {
|
| 224 |
+
"word": 615,
|
| 225 |
+
"phrase": 238
|
| 226 |
+
}
|
| 227 |
},
|
| 228 |
"baseline": {
|
| 229 |
+
"records": 10837,
|
| 230 |
"human_records": 0,
|
| 231 |
"human_share": 0.0,
|
| 232 |
"corpora": [
|
|
|
|
| 235 |
],
|
| 236 |
"by_corpus_type": {
|
| 237 |
"ui_strings": 7004,
|
| 238 |
+
"auto_mined": 3833
|
| 239 |
}
|
| 240 |
}
|
| 241 |
},
|
|
|
|
| 284 |
"tatoeba_challenge": 39
|
| 285 |
}
|
| 286 |
},
|
| 287 |
+
"lexicon": {
|
| 288 |
+
"entries": 2059,
|
| 289 |
+
"redistributable_entries": 2059,
|
| 290 |
+
"sources": [
|
| 291 |
+
"chikhapo"
|
| 292 |
+
],
|
| 293 |
+
"by_entry_type": {
|
| 294 |
+
"word": 1373,
|
| 295 |
+
"phrase": 685,
|
| 296 |
+
"example_sentence": 1
|
| 297 |
+
}
|
| 298 |
+
},
|
| 299 |
"baseline": {
|
| 300 |
"records": 2894,
|
| 301 |
"human_records": 0,
|
|
|
|
| 347 |
]
|
| 348 |
},
|
| 349 |
"evaluation": {
|
| 350 |
+
"records": 5861,
|
| 351 |
+
"test": 3861,
|
| 352 |
"dev": 2000,
|
| 353 |
"sources": [
|
| 354 |
+
"dolma_bitext",
|
| 355 |
"parme",
|
| 356 |
"smol"
|
| 357 |
],
|
| 358 |
"by_source": {
|
| 359 |
+
"dolma_bitext": 998,
|
| 360 |
"parme": 4000,
|
| 361 |
"smol": 863
|
| 362 |
}
|
| 363 |
},
|
| 364 |
+
"lexicon": {
|
| 365 |
+
"entries": 3990,
|
| 366 |
+
"redistributable_entries": 0,
|
| 367 |
+
"sources": [
|
| 368 |
+
"gilaki_top1000"
|
| 369 |
+
],
|
| 370 |
+
"by_entry_type": {
|
| 371 |
+
"word": 1993,
|
| 372 |
+
"example_sentence": 1997
|
| 373 |
+
}
|
| 374 |
+
},
|
| 375 |
"baseline": {
|
| 376 |
+
"records": 1677,
|
| 377 |
"human_records": 0,
|
| 378 |
"human_share": 0.0,
|
| 379 |
"corpora": [
|
|
|
|
| 381 |
"wikimedia"
|
| 382 |
],
|
| 383 |
"by_corpus_type": {
|
| 384 |
+
"ui_strings": 983,
|
| 385 |
"auto_mined": 694
|
| 386 |
}
|
| 387 |
}
|
|
|
|
| 426 |
]
|
| 427 |
},
|
| 428 |
"evaluation": {
|
| 429 |
+
"records": 2162,
|
| 430 |
+
"test": 2162,
|
| 431 |
"dev": 0,
|
| 432 |
"sources": [
|
| 433 |
+
"codet",
|
| 434 |
"tatoeba_challenge"
|
| 435 |
],
|
| 436 |
"by_source": {
|
| 437 |
+
"codet": 1408,
|
| 438 |
"tatoeba_challenge": 754
|
| 439 |
}
|
| 440 |
},
|
| 441 |
+
"lexicon": {
|
| 442 |
+
"entries": 9486,
|
| 443 |
+
"redistributable_entries": 9486,
|
| 444 |
+
"sources": [
|
| 445 |
+
"chikhapo"
|
| 446 |
+
],
|
| 447 |
+
"by_entry_type": {
|
| 448 |
+
"phrase": 3282,
|
| 449 |
+
"word": 6157,
|
| 450 |
+
"example_sentence": 47
|
| 451 |
+
}
|
| 452 |
+
},
|
| 453 |
"baseline": {
|
| 454 |
"records": 23625,
|
| 455 |
"human_records": 0,
|
|
|
|
| 498 |
"tatoeba_challenge": 3388
|
| 499 |
}
|
| 500 |
},
|
| 501 |
+
"lexicon": {
|
| 502 |
+
"entries": 66051,
|
| 503 |
+
"redistributable_entries": 66051,
|
| 504 |
+
"sources": [
|
| 505 |
+
"chikhapo"
|
| 506 |
+
],
|
| 507 |
+
"by_entry_type": {
|
| 508 |
+
"word": 54574,
|
| 509 |
+
"phrase": 11426,
|
| 510 |
+
"example_sentence": 51
|
| 511 |
+
}
|
| 512 |
+
},
|
| 513 |
"baseline": {
|
| 514 |
"records": 7294,
|
| 515 |
"human_records": 2217,
|
|
|
|
| 562 |
]
|
| 563 |
},
|
| 564 |
"evaluation": {
|
| 565 |
+
"records": 2509,
|
| 566 |
+
"test": 2264,
|
| 567 |
"dev": 245,
|
| 568 |
"sources": [
|
| 569 |
+
"codet",
|
| 570 |
"tatoeba_challenge",
|
| 571 |
"xsid"
|
| 572 |
],
|
| 573 |
"by_source": {
|
| 574 |
+
"codet": 1814,
|
| 575 |
"tatoeba_challenge": 2,
|
| 576 |
"xsid": 693
|
| 577 |
}
|
| 578 |
},
|
| 579 |
+
"lexicon": {
|
| 580 |
+
"entries": 14020,
|
| 581 |
+
"redistributable_entries": 14020,
|
| 582 |
+
"sources": [
|
| 583 |
+
"chikhapo"
|
| 584 |
+
],
|
| 585 |
+
"by_entry_type": {
|
| 586 |
+
"word": 11844,
|
| 587 |
+
"phrase": 2173,
|
| 588 |
+
"example_sentence": 3
|
| 589 |
+
}
|
| 590 |
+
},
|
| 591 |
"baseline": {
|
| 592 |
"records": 11342,
|
| 593 |
"human_records": 31,
|
|
|
|
| 653 |
"parme": 4000
|
| 654 |
}
|
| 655 |
},
|
| 656 |
+
"lexicon": {
|
| 657 |
+
"entries": 1529,
|
| 658 |
+
"redistributable_entries": 1529,
|
| 659 |
+
"sources": [
|
| 660 |
+
"chikhapo"
|
| 661 |
+
],
|
| 662 |
+
"by_entry_type": {
|
| 663 |
+
"phrase": 617,
|
| 664 |
+
"word": 910,
|
| 665 |
+
"example_sentence": 2
|
| 666 |
+
}
|
| 667 |
+
},
|
| 668 |
"baseline": {
|
| 669 |
"records": 5654,
|
| 670 |
"human_records": 0,
|
|
|
|
| 722 |
]
|
| 723 |
},
|
| 724 |
"evaluation": {
|
| 725 |
+
"records": 2583,
|
| 726 |
+
"test": 2583,
|
| 727 |
"dev": 0,
|
| 728 |
"sources": [
|
| 729 |
+
"codet",
|
| 730 |
"tatoeba_challenge"
|
| 731 |
],
|
| 732 |
"by_source": {
|
| 733 |
+
"codet": 2188,
|
| 734 |
"tatoeba_challenge": 395
|
| 735 |
}
|
| 736 |
},
|
| 737 |
+
"lexicon": {
|
| 738 |
+
"entries": 472,
|
| 739 |
+
"redistributable_entries": 472,
|
| 740 |
+
"sources": [
|
| 741 |
+
"chikhapo"
|
| 742 |
+
],
|
| 743 |
+
"by_entry_type": {
|
| 744 |
+
"word": 393,
|
| 745 |
+
"phrase": 79
|
| 746 |
+
}
|
| 747 |
+
},
|
| 748 |
"baseline": {
|
| 749 |
+
"records": 966,
|
| 750 |
"human_records": 0,
|
| 751 |
"human_share": 0.0,
|
| 752 |
"corpora": [
|
|
|
|
| 755 |
],
|
| 756 |
"by_corpus_type": {
|
| 757 |
"auto_mined": 550,
|
| 758 |
+
"ui_strings": 416
|
| 759 |
}
|
| 760 |
}
|
| 761 |
},
|
|
|
|
| 792 |
"tatoeba_challenge": 2077
|
| 793 |
}
|
| 794 |
},
|
| 795 |
+
"lexicon": {
|
| 796 |
+
"entries": 402,
|
| 797 |
+
"redistributable_entries": 402,
|
| 798 |
+
"sources": [
|
| 799 |
+
"chikhapo"
|
| 800 |
+
],
|
| 801 |
+
"by_entry_type": {
|
| 802 |
+
"word": 400,
|
| 803 |
+
"phrase": 2
|
| 804 |
+
}
|
| 805 |
+
},
|
| 806 |
"baseline": {
|
| 807 |
"records": 2100,
|
| 808 |
"human_records": 48,
|
|
|
|
| 852 |
]
|
| 853 |
},
|
| 854 |
"evaluation": {
|
| 855 |
+
"records": 2999,
|
| 856 |
+
"test": 1926,
|
| 857 |
"dev": 1073,
|
| 858 |
"sources": [
|
| 859 |
+
"maibaam",
|
| 860 |
"nalibasid",
|
| 861 |
"tatoeba_challenge",
|
| 862 |
"xsid"
|
| 863 |
],
|
| 864 |
"by_source": {
|
| 865 |
+
"maibaam": 59,
|
| 866 |
"nalibasid": 2722,
|
| 867 |
"tatoeba_challenge": 216,
|
| 868 |
"xsid": 2
|
| 869 |
}
|
| 870 |
},
|
| 871 |
+
"lexicon": {
|
| 872 |
+
"entries": 5345,
|
| 873 |
+
"redistributable_entries": 5345,
|
| 874 |
+
"sources": [
|
| 875 |
+
"chikhapo"
|
| 876 |
+
],
|
| 877 |
+
"by_entry_type": {
|
| 878 |
+
"word": 4896,
|
| 879 |
+
"phrase": 440,
|
| 880 |
+
"example_sentence": 9
|
| 881 |
+
}
|
| 882 |
+
},
|
| 883 |
"baseline": {
|
| 884 |
"records": 268537,
|
| 885 |
"human_records": 40,
|
|
|
|
| 939 |
"tatoeba_challenge": 506
|
| 940 |
}
|
| 941 |
},
|
| 942 |
+
"lexicon": {
|
| 943 |
+
"entries": 729,
|
| 944 |
+
"redistributable_entries": 729,
|
| 945 |
+
"sources": [
|
| 946 |
+
"chikhapo"
|
| 947 |
+
],
|
| 948 |
+
"by_entry_type": {
|
| 949 |
+
"word": 696,
|
| 950 |
+
"phrase": 33
|
| 951 |
+
}
|
| 952 |
+
},
|
| 953 |
"baseline": {
|
| 954 |
"records": 4786,
|
| 955 |
"human_records": 124,
|
|
|
|
| 1008 |
"tatoeba_challenge": 143
|
| 1009 |
}
|
| 1010 |
},
|
| 1011 |
+
"lexicon": {
|
| 1012 |
+
"entries": 13375,
|
| 1013 |
+
"redistributable_entries": 6234,
|
| 1014 |
+
"sources": [
|
| 1015 |
+
"apertium",
|
| 1016 |
+
"chikhapo"
|
| 1017 |
+
],
|
| 1018 |
+
"by_entry_type": {
|
| 1019 |
+
"word": 12106,
|
| 1020 |
+
"example_sentence": 45,
|
| 1021 |
+
"phrase": 1224
|
| 1022 |
+
}
|
| 1023 |
+
},
|
| 1024 |
"baseline": {
|
| 1025 |
"records": 25457,
|
| 1026 |
"human_records": 3158,
|
|
|
|
| 1068 |
]
|
| 1069 |
},
|
| 1070 |
"evaluation": {
|
| 1071 |
+
"records": 3349,
|
| 1072 |
+
"test": 2103,
|
| 1073 |
+
"dev": 1246,
|
| 1074 |
+
"sources": [
|
| 1075 |
+
"bouquet"
|
| 1076 |
+
],
|
| 1077 |
+
"by_source": {
|
| 1078 |
+
"bouquet": 3349
|
| 1079 |
+
}
|
| 1080 |
+
},
|
| 1081 |
+
"lexicon": {
|
| 1082 |
+
"entries": 512,
|
| 1083 |
+
"redistributable_entries": 512,
|
| 1084 |
+
"sources": [
|
| 1085 |
+
"chikhapo"
|
| 1086 |
+
],
|
| 1087 |
+
"by_entry_type": {
|
| 1088 |
+
"word": 498,
|
| 1089 |
+
"phrase": 14
|
| 1090 |
+
}
|
| 1091 |
},
|
| 1092 |
"baseline": {
|
| 1093 |
+
"records": 99398,
|
| 1094 |
+
"human_records": 1099,
|
| 1095 |
"human_share": 0.0111,
|
| 1096 |
"corpora": [
|
| 1097 |
"Tatoeba",
|
|
|
|
| 1103 |
"by_corpus_type": {
|
| 1104 |
"auto_mined": 65202,
|
| 1105 |
"entity_list": 33086,
|
| 1106 |
+
"crowd_sentences": 1099,
|
| 1107 |
"ui_strings": 11
|
| 1108 |
}
|
| 1109 |
}
|
|
|
|
| 1141 |
"tatoeba_challenge": 5368
|
| 1142 |
}
|
| 1143 |
},
|
| 1144 |
+
"lexicon": {
|
| 1145 |
+
"entries": 28607,
|
| 1146 |
+
"redistributable_entries": 28607,
|
| 1147 |
+
"sources": [
|
| 1148 |
+
"chikhapo"
|
| 1149 |
+
],
|
| 1150 |
+
"by_entry_type": {
|
| 1151 |
+
"word": 26891,
|
| 1152 |
+
"phrase": 1715,
|
| 1153 |
+
"example_sentence": 1
|
| 1154 |
+
}
|
| 1155 |
+
},
|
| 1156 |
"baseline": {
|
| 1157 |
"records": 24065,
|
| 1158 |
"human_records": 18157,
|
|
|
|
| 1196 |
]
|
| 1197 |
},
|
| 1198 |
"evaluation": {
|
| 1199 |
+
"records": 228,
|
| 1200 |
+
"test": 228,
|
| 1201 |
"dev": 0,
|
| 1202 |
"sources": [
|
| 1203 |
+
"tatoeba_challenge",
|
| 1204 |
+
"ud_megrelian"
|
| 1205 |
],
|
| 1206 |
"by_source": {
|
| 1207 |
+
"tatoeba_challenge": 79,
|
| 1208 |
+
"ud_megrelian": 149
|
| 1209 |
+
}
|
| 1210 |
+
},
|
| 1211 |
+
"lexicon": {
|
| 1212 |
+
"entries": 452,
|
| 1213 |
+
"redistributable_entries": 452,
|
| 1214 |
+
"sources": [
|
| 1215 |
+
"chikhapo"
|
| 1216 |
+
],
|
| 1217 |
+
"by_entry_type": {
|
| 1218 |
+
"phrase": 44,
|
| 1219 |
+
"word": 408
|
| 1220 |
}
|
| 1221 |
},
|
| 1222 |
"baseline": {
|
|
|
|
| 1268 |
"tatoeba_challenge": 19292
|
| 1269 |
}
|
| 1270 |
},
|
| 1271 |
+
"lexicon": {
|
| 1272 |
+
"entries": 50593,
|
| 1273 |
+
"redistributable_entries": 48144,
|
| 1274 |
+
"sources": [
|
| 1275 |
+
"apertium",
|
| 1276 |
+
"chikhapo"
|
| 1277 |
+
],
|
| 1278 |
+
"by_entry_type": {
|
| 1279 |
+
"word": 44709,
|
| 1280 |
+
"example_sentence": 27,
|
| 1281 |
+
"phrase": 5857
|
| 1282 |
+
}
|
| 1283 |
+
},
|
| 1284 |
"baseline": {
|
| 1285 |
"records": 225567,
|
| 1286 |
"human_records": 30146,
|
|
|
|
| 1337 |
]
|
| 1338 |
},
|
| 1339 |
"evaluation": {
|
| 1340 |
+
"records": 7193,
|
| 1341 |
+
"test": 6993,
|
| 1342 |
+
"dev": 200,
|
| 1343 |
+
"sources": [
|
| 1344 |
+
"nllb_seed",
|
| 1345 |
+
"nusax"
|
| 1346 |
+
],
|
| 1347 |
+
"by_source": {
|
| 1348 |
+
"nllb_seed": 6193,
|
| 1349 |
+
"nusax": 1000
|
| 1350 |
+
}
|
| 1351 |
+
},
|
| 1352 |
+
"lexicon": {
|
| 1353 |
+
"entries": 5445,
|
| 1354 |
+
"redistributable_entries": 5445,
|
| 1355 |
+
"sources": [
|
| 1356 |
+
"chikhapo",
|
| 1357 |
+
"nusax_lexicon"
|
| 1358 |
+
],
|
| 1359 |
+
"by_entry_type": {
|
| 1360 |
+
"phrase": 594,
|
| 1361 |
+
"word": 4845,
|
| 1362 |
+
"example_sentence": 6
|
| 1363 |
+
}
|
| 1364 |
},
|
| 1365 |
"baseline": {
|
| 1366 |
+
"records": 227642,
|
| 1367 |
"human_records": 1489,
|
| 1368 |
+
"human_share": 0.0065,
|
| 1369 |
"corpora": [
|
| 1370 |
"NLLB",
|
| 1371 |
"QED",
|
|
|
|
| 1373 |
"wikimedia"
|
| 1374 |
],
|
| 1375 |
"by_corpus_type": {
|
| 1376 |
+
"auto_mined": 225595,
|
| 1377 |
"subtitles": 1489,
|
| 1378 |
"ui_strings": 558
|
| 1379 |
}
|
|
|
|
| 1409 |
]
|
| 1410 |
},
|
| 1411 |
"evaluation": {
|
| 1412 |
+
"records": 105,
|
| 1413 |
+
"test": 105,
|
| 1414 |
"dev": 0,
|
| 1415 |
+
"sources": [
|
| 1416 |
+
"glotstorybook"
|
| 1417 |
+
],
|
| 1418 |
+
"by_source": {
|
| 1419 |
+
"glotstorybook": 105
|
| 1420 |
+
}
|
| 1421 |
+
},
|
| 1422 |
+
"lexicon": {
|
| 1423 |
+
"entries": 226,
|
| 1424 |
+
"redistributable_entries": 226,
|
| 1425 |
+
"sources": [
|
| 1426 |
+
"chikhapo"
|
| 1427 |
+
],
|
| 1428 |
+
"by_entry_type": {
|
| 1429 |
+
"word": 225,
|
| 1430 |
+
"phrase": 1
|
| 1431 |
+
}
|
| 1432 |
},
|
| 1433 |
"baseline": {
|
| 1434 |
"records": 7706,
|
|
|
|
| 1474 |
"tatoeba_challenge": 80
|
| 1475 |
}
|
| 1476 |
},
|
| 1477 |
+
"lexicon": {
|
| 1478 |
+
"entries": 11871,
|
| 1479 |
+
"redistributable_entries": 11871,
|
| 1480 |
+
"sources": [
|
| 1481 |
+
"chikhapo"
|
| 1482 |
+
],
|
| 1483 |
+
"by_entry_type": {
|
| 1484 |
+
"word": 6514,
|
| 1485 |
+
"phrase": 5339,
|
| 1486 |
+
"example_sentence": 18
|
| 1487 |
+
}
|
| 1488 |
+
},
|
| 1489 |
"baseline": {
|
| 1490 |
"records": 357,
|
| 1491 |
"human_records": 28,
|
|
|
|
| 1539 |
]
|
| 1540 |
},
|
| 1541 |
"evaluation": {
|
| 1542 |
+
"records": 3348,
|
| 1543 |
+
"test": 2102,
|
| 1544 |
+
"dev": 1246,
|
| 1545 |
+
"sources": [
|
| 1546 |
+
"bouquet"
|
| 1547 |
+
],
|
| 1548 |
+
"by_source": {
|
| 1549 |
+
"bouquet": 3348
|
| 1550 |
+
}
|
| 1551 |
+
},
|
| 1552 |
+
"lexicon": {
|
| 1553 |
+
"entries": 4251,
|
| 1554 |
+
"redistributable_entries": 4251,
|
| 1555 |
+
"sources": [
|
| 1556 |
+
"chikhapo"
|
| 1557 |
+
],
|
| 1558 |
+
"by_entry_type": {
|
| 1559 |
+
"word": 2772,
|
| 1560 |
+
"phrase": 1460,
|
| 1561 |
+
"example_sentence": 19
|
| 1562 |
+
}
|
| 1563 |
},
|
| 1564 |
"baseline": {
|
| 1565 |
"records": 24777,
|
selected_languages.md
CHANGED
|
@@ -2,33 +2,31 @@
|
|
| 2 |
|
| 3 |
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.
|
| 4 |
|
| 5 |
-
Audit release `finewiki_audit_20261114T182048Z`; 22 languages,
|
| 6 |
|
| 7 |
-
| # | config | ISO | language | family | articles | pivots | eval | baseline | human baseline |
|
| 8 |
-
|--:|---|---|---|---|--:|---|--:|--:|--:|
|
| 9 |
-
| 1 | `als` | gsw | Alemannisch | Indo-European | 29,141 | `af`, `de`, `en`, `fr`, `lb` | 5,677 | 182 | 4 |
|
| 10 |
-
| 2 | `lld` | lld | Ladin | Indo-European | 180,820 | `ca`, `de`, `en`, `es`, `it`, `vec` |
|
| 11 |
-
| 4 | `azb` | azb | تۆرکجه | Turkic | 224,284 | `az`, `ba`, `en`, `kk`, `tr` |
|
| 12 |
-
| 5 | `bat_smg` | sgs | žemaitėška | Indo-European | 17,089 | `be`, `bg`, `en`, `lt`, `lv` | 39 | 2,894 | 0 |
|
| 13 |
-
| 7 | `glk` | glk | گیلکی | Indo-European | 47,607 | `ckb`, `en`, `fa`, `ku`, `mzn`, `tg` |
|
| 14 |
-
| 8 | `pms` | pms | Piemontèis | Indo-European | 69,013 | `ca`, `en`, `es`, `fr`, `ht`, `it`, `lmo` |
|
| 15 |
-
| 9 | `vo` | vol | Volapük | Artificial Language | 41,550 | `en`, `eo` | 3,388 | 7,294 | 2,217 |
|
| 16 |
-
| 11 | `nap` | nap | Napulitano | Indo-European | 14,753 | `ca`, `en`, `es`, `it`, `vec` |
|
| 17 |
-
| 13 | `mzn` | mzn | مازِرونی | Indo-European | 63,403 | `ckb`, `en`, `es`, `fa`, `ku`, `tg` | 4,000 | 5,654 | 0 |
|
| 18 |
-
| 16 | `eml` | egl | emiliàn e rumagnòl | Indo-European | 13,525 | `ca`, `en`, `fr`, `ht`, `it`, `lmo`, `oc`, `ur` |
|
| 19 |
-
| 17 | `avk` | avk | Kotava | Artificial Language | 26,979 | `en`, `eo` | 2,077 | 2,100 | 48 |
|
| 20 |
-
| 18 | `bar` | bar | Boarisch | Indo-European | 23,542 | `af`, `de`, `en`, `lb` | 2,
|
| 21 |
-
| 19 | `frr` | frr | Nordfriisk | Indo-European | 18,723 | `af`, `de`, `en` | 506 | 4,786 | 124 |
|
| 22 |
-
| 20 | `sco` | sco | Scots | Indo-European | 32,294 | `af`, `de`, `en`, `it` | 143 | 25,457 | 3,158 |
|
| 23 |
-
| 21 | `wuu` | wuu | 吴语 | Sino-Tibetan | 45,237 | `en`, `zh`, `zh_yue` |
|
| 24 |
-
| 22 | `ie` | ile | Interlingue | Artificial Language | 13,311 | `en`, `eo` | 5,368 | 24,065 | 18,157 |
|
| 25 |
-
| 24 | `xmf` | xmf | მარგალური | Kartvelian | 21,832 | `en`, `ka` |
|
| 26 |
-
| 28 | `ia` | ina | interlingua | Artificial Language | 29,333 | `en`, `eo` | 19,292 | 225,567 | 30,146 |
|
| 27 |
-
| 47 | `bug` | bug | Basa Ugi | Austronesian | 15,954 | `ceb`, `en`, `id`, `jv`, `mg`, `ms` |
|
| 28 |
-
| 53 | `dag` | dag | dagbanli | Atlantic-Congo | 14,693 | `en`, `ig`, `sw`, `yo` |
|
| 29 |
-
| 58 | `nv` | nav | Diné bizaad | Athabaskan-Eyak-Tlingit | 22,538 | `en` | 80 | 357 | 28 |
|
| 30 |
-
| 73 | `skr` | skr | سرائیکی | Indo-European | 24,072 | `bn`, `en`, `hi`, `mr`, `pa`, `ur` |
|
| 31 |
|
| 32 |
-
`
|
| 33 |
-
|
| 34 |
-
`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.
|
|
|
|
| 2 |
|
| 3 |
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.
|
| 4 |
|
| 5 |
+
Audit release `finewiki_audit_20261114T182048Z`; 22 languages, 22 of them with evaluation data.
|
| 6 |
|
| 7 |
+
| # | config | ISO | language | family | articles | pivots | eval | lexicon | baseline | human baseline |
|
| 8 |
+
|--:|---|---|---|---|--:|---|--:|--:|--:|--:|
|
| 9 |
+
| 1 | `als` | gsw | Alemannisch | Indo-European | 29,141 | `af`, `de`, `en`, `fr`, `lb` | 5,677 | 10,973 | 182 | 4 |
|
| 10 |
+
| 2 | `lld` | lld | Ladin | Indo-European | 180,820 | `ca`, `de`, `en`, `es`, `it`, `vec` | 436 | 53,113 | 4,431 | 107 |
|
| 11 |
+
| 4 | `azb` | azb | تۆرکجه | Turkic | 224,284 | `az`, `ba`, `en`, `kk`, `tr` | 3,348 | 853 | 10,837 | 0 |
|
| 12 |
+
| 5 | `bat_smg` | sgs | žemaitėška | Indo-European | 17,089 | `be`, `bg`, `en`, `lt`, `lv` | 39 | 2,059 | 2,894 | 0 |
|
| 13 |
+
| 7 | `glk` | glk | گیلکی | Indo-European | 47,607 | `ckb`, `en`, `fa`, `ku`, `mzn`, `tg` | 5,861 | 3,990 | 1,677 | 0 |
|
| 14 |
+
| 8 | `pms` | pms | Piemontèis | Indo-European | 69,013 | `ca`, `en`, `es`, `fr`, `ht`, `it`, `lmo` | 2,162 | 9,486 | 23,625 | 0 |
|
| 15 |
+
| 9 | `vo` | vol | Volapük | Artificial Language | 41,550 | `en`, `eo` | 3,388 | 66,051 | 7,294 | 2,217 |
|
| 16 |
+
| 11 | `nap` | nap | Napulitano | Indo-European | 14,753 | `ca`, `en`, `es`, `it`, `vec` | 2,509 | 14,020 | 11,342 | 31 |
|
| 17 |
+
| 13 | `mzn` | mzn | مازِرونی | Indo-European | 63,403 | `ckb`, `en`, `es`, `fa`, `ku`, `tg` | 4,000 | 1,529 | 5,654 | 0 |
|
| 18 |
+
| 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 |
|
| 19 |
+
| 17 | `avk` | avk | Kotava | Artificial Language | 26,979 | `en`, `eo` | 2,077 | 402 | 2,100 | 48 |
|
| 20 |
+
| 18 | `bar` | bar | Boarisch | Indo-European | 23,542 | `af`, `de`, `en`, `lb` | 2,999 | 5,345 | 268,537 | 40 |
|
| 21 |
+
| 19 | `frr` | frr | Nordfriisk | Indo-European | 18,723 | `af`, `de`, `en` | 506 | 729 | 4,786 | 124 |
|
| 22 |
+
| 20 | `sco` | sco | Scots | Indo-European | 32,294 | `af`, `de`, `en`, `it` | 143 | 13,375 | 25,457 | 3,158 |
|
| 23 |
+
| 21 | `wuu` | wuu | 吴语 | Sino-Tibetan | 45,237 | `en`, `zh`, `zh_yue` | 3,349 | 512 | 99,398 | 1,099 |
|
| 24 |
+
| 22 | `ie` | ile | Interlingue | Artificial Language | 13,311 | `en`, `eo` | 5,368 | 28,607 | 24,065 | 18,157 |
|
| 25 |
+
| 24 | `xmf` | xmf | მარგალური | Kartvelian | 21,832 | `en`, `ka` | 228 | 452 | 11,963 | 119 |
|
| 26 |
+
| 28 | `ia` | ina | interlingua | Artificial Language | 29,333 | `en`, `eo` | 19,292 | 50,593 | 225,567 | 30,146 |
|
| 27 |
+
| 47 | `bug` | bug | Basa Ugi | Austronesian | 15,954 | `ceb`, `en`, `id`, `jv`, `mg`, `ms` | 7,193 | 5,445 | 227,642 | 1,489 |
|
| 28 |
+
| 53 | `dag` | dag | dagbanli | Atlantic-Congo | 14,693 | `en`, `ig`, `sw`, `yo` | 105 | 226 | 7,706 | 0 |
|
| 29 |
+
| 58 | `nv` | nav | Diné bizaad | Athabaskan-Eyak-Tlingit | 22,538 | `en` | 80 | 11,871 | 357 | 28 |
|
| 30 |
+
| 73 | `skr` | skr | سرائیکی | Indo-European | 24,072 | `bn`, `en`, `hi`, `mr`, `pa`, `ur` | 3,348 | 4,251 | 24,777 | 84 |
|
| 31 |
|
| 32 |
+
`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.
|
|
|
|
|
|
tests/test_eval_corpus.py
CHANGED
|
@@ -173,8 +173,9 @@ class FloresWithholding(unittest.TestCase):
|
|
| 173 |
made = evalc.collect_flores_reference(["wuu"], rows)
|
| 174 |
self.assertEqual(len(made), 2) # dev and test
|
| 175 |
for record in made:
|
| 176 |
-
|
| 177 |
-
self.
|
|
|
|
| 178 |
self.assertTrue(record["text_withheld"])
|
| 179 |
self.assertIn("crawlers", record["withheld_reason"])
|
| 180 |
|
|
@@ -409,19 +410,38 @@ class ReleaseIntegrity(unittest.TestCase):
|
|
| 409 |
for line in handle:
|
| 410 |
record = json.loads(line)
|
| 411 |
if record.get("text_withheld"):
|
| 412 |
-
self.
|
| 413 |
continue
|
| 414 |
self.assertTrue(record["src"].strip())
|
| 415 |
self.assertTrue(record["trg"].strip())
|
| 416 |
|
| 417 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 418 |
for path in (self.eval_release / "languages").glob("*.jsonl"):
|
| 419 |
with path.open(encoding="utf-8") as handle:
|
| 420 |
for line in handle:
|
| 421 |
record = json.loads(line)
|
| 422 |
-
if record.get("source")
|
| 423 |
-
|
| 424 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 425 |
|
| 426 |
def test_ids_are_contiguous_within_each_language(self):
|
| 427 |
for path in (self.eval_release / "languages").glob("*.jsonl"):
|
|
|
|
| 173 |
made = evalc.collect_flores_reference(["wuu"], rows)
|
| 174 |
self.assertEqual(len(made), 2) # dev and test
|
| 175 |
for record in made:
|
| 176 |
+
# Withheld rows carry empty text rather than null, uniformly across sources.
|
| 177 |
+
self.assertEqual(record["src"], "")
|
| 178 |
+
self.assertEqual(record["trg"], "")
|
| 179 |
self.assertTrue(record["text_withheld"])
|
| 180 |
self.assertIn("crawlers", record["withheld_reason"])
|
| 181 |
|
|
|
|
| 410 |
for line in handle:
|
| 411 |
record = json.loads(line)
|
| 412 |
if record.get("text_withheld"):
|
| 413 |
+
self.assertEqual(record.get("src", ""), "")
|
| 414 |
continue
|
| 415 |
self.assertTrue(record["src"].strip())
|
| 416 |
self.assertTrue(record["trg"].strip())
|
| 417 |
|
| 418 |
+
def test_no_withheld_source_leaks_its_text(self):
|
| 419 |
+
"""Generalised from the FLORES+ case: every tier-3 source must be textless.
|
| 420 |
+
|
| 421 |
+
FLORES+ is no longer the only source we are not allowed to pass on, so checking it
|
| 422 |
+
by name would let the next one through unnoticed.
|
| 423 |
+
"""
|
| 424 |
+
withheld_sources = {
|
| 425 |
+
name for name, meta in evalc.SOURCE_META.items()
|
| 426 |
+
if meta["tier"] == evalc.TIER_REFERENCE
|
| 427 |
+
}
|
| 428 |
+
self.assertIn("flores_plus", withheld_sources)
|
| 429 |
+
seen = set()
|
| 430 |
for path in (self.eval_release / "languages").glob("*.jsonl"):
|
| 431 |
with path.open(encoding="utf-8") as handle:
|
| 432 |
for line in handle:
|
| 433 |
record = json.loads(line)
|
| 434 |
+
if record.get("source") not in withheld_sources:
|
| 435 |
+
continue
|
| 436 |
+
seen.add(record["source"])
|
| 437 |
+
with self.subTest(source=record["source"], language=record["tl"]):
|
| 438 |
+
self.assertEqual(record.get("src") or "", "")
|
| 439 |
+
self.assertEqual(record.get("trg") or "", "")
|
| 440 |
+
self.assertTrue(record["text_withheld"])
|
| 441 |
+
self.assertFalse(record["redistributable"])
|
| 442 |
+
# The row still has to say what it stands for.
|
| 443 |
+
self.assertTrue(record.get("upstream_rows"))
|
| 444 |
+
self.assertTrue(seen, "no withheld rows found in the release at all")
|
| 445 |
|
| 446 |
def test_ids_are_contiguous_within_each_language(self):
|
| 447 |
for path in (self.eval_release / "languages").glob("*.jsonl"):
|
tests/test_lexicon_corpus.py
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Tests for the lexicon corpus and for the licence tiering both corpora share."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import json
|
| 6 |
+
import sys
|
| 7 |
+
import unittest
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 11 |
+
sys.path.insert(0, str(ROOT / "scripts"))
|
| 12 |
+
|
| 13 |
+
import build_eval_corpus as evalc # noqa: E402
|
| 14 |
+
import build_lexicon_corpus as lex # noqa: E402
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class EntryTypes(unittest.TestCase):
|
| 18 |
+
def test_a_single_token_is_a_word(self):
|
| 19 |
+
self.assertEqual(lex._entry_type("Hoibe"), "word")
|
| 20 |
+
|
| 21 |
+
def test_a_short_multiword_gloss_is_a_phrase(self):
|
| 22 |
+
self.assertEqual(lex._entry_type("ti dé de n pe"), "phrase")
|
| 23 |
+
|
| 24 |
+
def test_a_terminated_sentence_is_an_example(self):
|
| 25 |
+
self.assertEqual(lex._entry_type("Mr. Mahmoud is a good person."),
|
| 26 |
+
"example_sentence")
|
| 27 |
+
|
| 28 |
+
def test_a_long_run_without_punctuation_is_still_an_example(self):
|
| 29 |
+
self.assertEqual(
|
| 30 |
+
lex._entry_type("آقا محمود آدم خوبى است و همه او را دوست دارند"),
|
| 31 |
+
"example_sentence",
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
def test_persian_question_mark_terminates_a_sentence(self):
|
| 35 |
+
self.assertEqual(lex._entry_type("چه خبر؟"), "example_sentence")
|
| 36 |
+
|
| 37 |
+
def test_empty_text_does_not_raise(self):
|
| 38 |
+
self.assertEqual(lex._entry_type(""), "word")
|
| 39 |
+
self.assertEqual(lex._entry_type(None), "word")
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class ApertiumDictionaries(unittest.TestCase):
|
| 43 |
+
DIX = b"""<?xml version="1.0" encoding="UTF-8"?>
|
| 44 |
+
<dictionary>
|
| 45 |
+
<section id="main" type="standard">
|
| 46 |
+
<e><p><l>house<s n="n"/></l><r>hoose<s n="n"/></r></p></e>
|
| 47 |
+
<e><p><l>water</l><r>watter</r></p></e>
|
| 48 |
+
<e><i>radio</i></e>
|
| 49 |
+
<e><p><l>broken</l></p></e>
|
| 50 |
+
</section>
|
| 51 |
+
</dictionary>"""
|
| 52 |
+
|
| 53 |
+
def test_paired_entries_are_read(self):
|
| 54 |
+
pairs = lex._dix_pairs(self.DIX, "eng", "sco")
|
| 55 |
+
self.assertIn(("house", "hoose"), pairs)
|
| 56 |
+
self.assertIn(("water", "watter"), pairs)
|
| 57 |
+
|
| 58 |
+
def test_a_shared_form_entry_becomes_an_identical_pair(self):
|
| 59 |
+
self.assertIn(("radio", "radio"), lex._dix_pairs(self.DIX, "eng", "sco"))
|
| 60 |
+
|
| 61 |
+
def test_a_half_entry_is_skipped_rather_than_guessed(self):
|
| 62 |
+
pairs = lex._dix_pairs(self.DIX, "eng", "sco")
|
| 63 |
+
self.assertNotIn("broken", [left for left, _ in pairs])
|
| 64 |
+
self.assertEqual(len(pairs), 3)
|
| 65 |
+
|
| 66 |
+
def test_malformed_xml_yields_nothing_rather_than_raising(self):
|
| 67 |
+
self.assertEqual(lex._dix_pairs(b"<dictionary><e>", "eng", "sco"), [])
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
class LicenceTiers(unittest.TestCase):
|
| 71 |
+
def test_every_source_declares_a_tier(self):
|
| 72 |
+
for name, meta in lex.SOURCE_META.items():
|
| 73 |
+
with self.subTest(source=name):
|
| 74 |
+
self.assertIn(meta["tier"], (1, 2, 3))
|
| 75 |
+
self.assertTrue(meta["licence"])
|
| 76 |
+
|
| 77 |
+
def test_a_restricted_source_states_its_restriction(self):
|
| 78 |
+
for name, meta in lex.SOURCE_META.items():
|
| 79 |
+
if meta["tier"] == lex.TIER_RESTRICTED:
|
| 80 |
+
with self.subTest(source=name):
|
| 81 |
+
self.assertTrue(meta["restriction"],
|
| 82 |
+
f"{name} is restricted but says nothing about why")
|
| 83 |
+
|
| 84 |
+
def test_copyleft_sources_are_not_filed_as_freely_redistributable(self):
|
| 85 |
+
for name, meta in lex.SOURCE_META.items():
|
| 86 |
+
if "GPL" in meta["licence"] or "-NC" in meta["licence"]:
|
| 87 |
+
with self.subTest(source=name):
|
| 88 |
+
self.assertNotEqual(meta["tier"], lex.TIER_REDISTRIBUTABLE)
|
| 89 |
+
|
| 90 |
+
def test_a_reference_only_entry_carries_no_text(self):
|
| 91 |
+
lex.SOURCE_META["_probe"] = {
|
| 92 |
+
"url": "x", "revision": "1", "licence": "none stated",
|
| 93 |
+
"note": "", "tier": lex.TIER_REFERENCE, "restriction": "test",
|
| 94 |
+
}
|
| 95 |
+
try:
|
| 96 |
+
entry = lex.make_entry(pivot_config="en", target_config="glk",
|
| 97 |
+
src="secret", trg="secret", source="_probe",
|
| 98 |
+
entry_type="word")
|
| 99 |
+
finally:
|
| 100 |
+
del lex.SOURCE_META["_probe"]
|
| 101 |
+
self.assertEqual((entry["src"], entry["trg"]), ("", ""))
|
| 102 |
+
self.assertTrue(entry["text_withheld"])
|
| 103 |
+
self.assertFalse(entry["redistributable"])
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
class LexiconDeduplication(unittest.TestCase):
|
| 107 |
+
def _entry(self, source, tier, src="house", trg="hoose"):
|
| 108 |
+
return {"tl": "sco", "sl": "en", "src": src, "trg": trg,
|
| 109 |
+
"source": source, "licence_tier": tier}
|
| 110 |
+
|
| 111 |
+
def test_the_freest_copy_of_a_duplicate_wins(self):
|
| 112 |
+
kept, dropped = lex.deduplicate([
|
| 113 |
+
self._entry("apertium", lex.TIER_RESTRICTED),
|
| 114 |
+
self._entry("chikhapo", lex.TIER_REDISTRIBUTABLE),
|
| 115 |
+
])
|
| 116 |
+
self.assertEqual(len(kept), 1)
|
| 117 |
+
self.assertEqual(kept[0]["source"], "chikhapo")
|
| 118 |
+
self.assertEqual(len(dropped), 1)
|
| 119 |
+
|
| 120 |
+
def test_order_does_not_decide_the_winner(self):
|
| 121 |
+
for order in ([lex.TIER_REDISTRIBUTABLE, lex.TIER_RESTRICTED],
|
| 122 |
+
[lex.TIER_RESTRICTED, lex.TIER_REDISTRIBUTABLE]):
|
| 123 |
+
kept, _ = lex.deduplicate([self._entry(f"s{t}", t) for t in order])
|
| 124 |
+
self.assertEqual(kept[0]["licence_tier"], lex.TIER_REDISTRIBUTABLE)
|
| 125 |
+
|
| 126 |
+
def test_different_pairs_are_both_kept(self):
|
| 127 |
+
kept, _ = lex.deduplicate([
|
| 128 |
+
self._entry("chikhapo", 1, "house", "hoose"),
|
| 129 |
+
self._entry("chikhapo", 1, "water", "watter"),
|
| 130 |
+
])
|
| 131 |
+
self.assertEqual(len(kept), 2)
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
class EvalLicenceTiers(unittest.TestCase):
|
| 135 |
+
"""The same tiering, in the evaluation corpus."""
|
| 136 |
+
|
| 137 |
+
def test_every_eval_source_declares_a_tier(self):
|
| 138 |
+
for name, meta in evalc.SOURCE_META.items():
|
| 139 |
+
with self.subTest(source=name):
|
| 140 |
+
self.assertIn(meta["tier"], (1, 2, 3))
|
| 141 |
+
|
| 142 |
+
def test_reference_only_sources_withhold_their_text(self):
|
| 143 |
+
for name, meta in evalc.SOURCE_META.items():
|
| 144 |
+
if meta["tier"] != evalc.TIER_REFERENCE:
|
| 145 |
+
continue
|
| 146 |
+
with self.subTest(source=name):
|
| 147 |
+
record = evalc.make_record(
|
| 148 |
+
pivot_config="en", target_config="dag", src="secret", trg="secret",
|
| 149 |
+
source=name, split="test",
|
| 150 |
+
)
|
| 151 |
+
self.assertEqual((record["src"], record["trg"]), ("", ""))
|
| 152 |
+
self.assertTrue(record["text_withheld"])
|
| 153 |
+
self.assertTrue(record["withheld_reason"])
|
| 154 |
+
|
| 155 |
+
def test_a_redistributable_source_keeps_its_text(self):
|
| 156 |
+
record = evalc.make_record(
|
| 157 |
+
pivot_config="en", target_config="bar", src="Hello", trg="Servus",
|
| 158 |
+
source="maibaam", split="test",
|
| 159 |
+
)
|
| 160 |
+
self.assertEqual(record["trg"], "Servus")
|
| 161 |
+
self.assertTrue(record["redistributable"])
|
| 162 |
+
self.assertIsNone(record["licence_restriction"])
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
class ReleaseIntegrity(unittest.TestCase):
|
| 166 |
+
@classmethod
|
| 167 |
+
def setUpClass(cls):
|
| 168 |
+
releases = sorted((ROOT / "dist" / "lexicon_corpus").glob("lexicon_*"))
|
| 169 |
+
if not releases:
|
| 170 |
+
raise unittest.SkipTest("no lexicon release built yet")
|
| 171 |
+
cls.release = releases[-1]
|
| 172 |
+
cls.manifest = json.loads(
|
| 173 |
+
(cls.release / "manifest.json").read_text(encoding="utf-8")
|
| 174 |
+
)
|
| 175 |
+
|
| 176 |
+
def test_every_shortlist_language_has_a_file(self):
|
| 177 |
+
for config in self.manifest["languages"]:
|
| 178 |
+
self.assertTrue((self.release / "languages" / f"{config}.jsonl").exists())
|
| 179 |
+
|
| 180 |
+
def test_subsets_partition_the_release(self):
|
| 181 |
+
subsets = self.manifest["subsets"]
|
| 182 |
+
total = subsets["all"]["records"]
|
| 183 |
+
self.assertEqual(total, self.manifest["total_entries"])
|
| 184 |
+
self.assertEqual(sum(v["records"] for k, v in subsets.items() if k != "all"), total)
|
| 185 |
+
|
| 186 |
+
def test_tier_counts_sum_to_the_total(self):
|
| 187 |
+
self.assertEqual(sum(self.manifest["entries_by_licence_tier"].values()),
|
| 188 |
+
self.manifest["total_entries"])
|
| 189 |
+
|
| 190 |
+
def test_gilaki_has_entries_because_it_is_the_point_of_the_project(self):
|
| 191 |
+
self.assertGreater(self.manifest["languages"]["glk"]["entries"], 0)
|
| 192 |
+
|
| 193 |
+
def test_the_language_set_matches_the_evaluation_corpus(self):
|
| 194 |
+
eval_releases = sorted((ROOT / "dist" / "eval_corpus").glob("eval_*"))
|
| 195 |
+
if not eval_releases:
|
| 196 |
+
self.skipTest("no eval release built yet")
|
| 197 |
+
eval_manifest = json.loads(
|
| 198 |
+
(eval_releases[-1] / "manifest.json").read_text(encoding="utf-8")
|
| 199 |
+
)
|
| 200 |
+
self.assertEqual(set(self.manifest["languages"]),
|
| 201 |
+
set(eval_manifest["languages"]))
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
if __name__ == "__main__":
|
| 205 |
+
unittest.main()
|