A modular, JSON-based language database and validation pipeline for over 7,900 languages (ISO 639-3), including Uralic/Finno-Ugric languages. Designed for RSS feeds, localization, and NLP workflows.
- Author: Tuomas Lähteenmäki
- License: MIT
- Version: 1.0.2
- Canonical Repository (Codeberg): https://codeberg.org/lahtis/GLFM
- GitHub Mirror: https://github.com/lahtis/GLFM
- 7,900+ Languages: Unified from ISO 639-1/2/3/5, Wiktionary, CLDR, Glottolog, and POS statistics.
- Nearest Language Neighbors: Each written language includes typologically nearest languages based on URIEL/lang2vec features (syntax, phonology, inventory, family).
- Accurate BCP-47 Tags: Language, script, and region combined automatically.
- Fallback Chains: Automatically assigns fallback languages where applicable.
- Uralic/Finno-Ugric Support: Detailed mapping for Finnish, Karelian, Estonian, and related languages.
- Validation Pipeline: Full automated checks for ISO consistency, BCP-47 compliance, fallback correctness, POS stats, and Glottolog data.
- Graphviz Visualization: Fallback relationships can be visualized.
- Checkpoint/Resume Support: Long-running nearest-language computations can be resumed automatically from a checkpoint.
├── build_unified.py # Build unified JSON database
├── data/ # Raw and processed language data
│ ├── cldr/
│ │ └── likelySubtags.json
│ ├── iso_639_*.py # ISO datasets in Python format
│ ├── override_scripts.json
│ ├── uralic_languages.json
│ └── ...
├── loaders/ # Data loading modules
├── logic/ # Logic for scripts, regions, fallbacks, BCP-47
├── models/ # Data models (Language class, ISO modules)
├── output/ # Pipeline output
│ ├── unified/ # unified_languages.json
│ ├── validation/ # validation reports, errors, fallback graph
│ ├── final/
│ ├── dialects/
│ └── logs/
├── tools/ # Validation, report generation, and helpers
│ ├── compute_nearest_languages.py # Compute nearest language neighbors
│ └── ...
├── run_full_pipeline.py # Run full pipeline: build → validate → report
└── init.py
Each language is represented as a JSON object keyed by its ISO 639-3 code:
"fin": {
"bcp47": "fi-Latn-FI",
"default_region": "FI",
"default_script": "Latn",
"distance_bases": [
"WALS",
"SSWL",
"PHOIBLE",
"Ethnologue",
"Glottolog"
],
"distance_source": "lang2vec / URIEL",
"distance_type": "fam",
"fallback": "fin",
"family": "",
"glottocode": "",
"glottolog": {},
"id": "fin",
"iso639_1": "fi",
"iso639_2B": "fin",
"iso639_2T": "fin",
"iso639_3": "fin",
"iso639_5": "",
"name": "Finnish",
"nearest_languages": [
{
"lang": "est",
"distance": 0.0003
},
{
"lang": "izh",
"distance": 0.0003
},
{
"lang": "liv",
"distance": 0.0003
},
{
"lang": "vep",
"distance": 0.0003
},
{
"lang": "vot",
"distance": 0.0003
}
],
"official_name": "Finnish",
"pos_stats": {},
"uralicNLP": true,
"written": true,
"written_scripts": [
"Latn"
]
}bcp47is automatically generated:lang[-Script][-Region].fallbackis the default fallback language.uralicNLPis true if the language belongs to the Uralic/Finno-Ugric family.written_scriptslists all known writing scripts.nearest_languagesranks typologically nearest written languages by distance (0.0 = identical features, 1.0 = completely different).
The pipeline is fully automated:
- Generate ISO files (
tools/generate_iso_files.py) - Build Unified Database (
build_unified.py) - Compute Nearest Languages (
tools/compute_nearest_languages.py) – addsnearest_languagesfield to all written languages (supports checkpoint/resume for long runs) - Validate:
- BCP-47 tags (
validate_bcp47.py) - Fallback chains (
validate_fallbacks.py) - ISO consistency (
validate_iso_consistency.py) - POS statistics (
validate_pos_stats.py) - Glottolog data (
validate_glottolog.py)
- BCP-47 tags (
- Generate Validation Reports (
generate_report.py):- Markdown report (
validation_report.md) - HTML report (
validation_report.html) - JSON error log (
validation_errors.json)
- Markdown report (
- Visualize Fallback Graph (
visualize_fallbacks.py) - Build Supplemental Data:
- Extinct languages dataset (
build_extinct_json.py) - Top-5 fallback optimization (
build_top5.py)
- Extinct languages dataset (
- Compress & Convert Outputs:
- Standard library package (
compress_stdlib.py) - Binary dataset (
convert_to_msgpack.py)
- Standard library package (
- Python 3.8+
- Core dependencies:
numpy>=1.26.0,<2.0.0,setuptools>=69.0.0 - Language data:
lang2vec>=1.1.0 - Data processing:
requests>=2.28.0,msgpack>=1.0.5 - Visualization (optional):
graphviz>=0.20.0 - Testing (optional):
pytest>=7.0.0
git clone [https://codeberg.org/lahtis/GLFM.git](https://codeberg.org/lahtis/GLFM.git)
cd GLFM
pip install -r requirements.txt
python3 run_full_pipeline.pyIf you need to run or resume the heavy nearest-languages calculation separately:
python3 tools/compute_nearest_languages.pyNote: Checkpoints are saved automatically to output/unified/nearest_languages.checkpoint.json and allow interrupted runs to resume seamlessly.
python3 logic/build_extinct_json.pypython3 tools/build_top5.py --top-k 20Note: The build_top5.py script takes --top-k 20 (or -k 20) to specify how many fallback candidates are stored per language.
import json
from pathlib import Path
unified_file = Path("output/unified/unified_languages.json")
with unified_file.open("r", encoding="utf-8") as f:
languages = json.load(f)
# Access Finnish
finnish = languages.get("fin")
print(finnish["bcp47"]) # fi-Latn-FI
print(finnish["uralicNLP"]) # True
print(finnish["nearest_languages"][:5]) # Top 5 nearest languages# Get 10 nearest languages to Finnish
finnish = languages.get("fin", {})
for neighbor in finnish.get("nearest_languages", [])[:10]:
print(f"{neighbor['lang']}: {neighbor['distance']:.4f}")import gzip
import json
from pathlib import Path
# Load compressed database (.json.gz)
database_path = Path("output/unified/languages_top20.json.gz")
with gzip.open(database_path, "rt", encoding="utf-8") as f:
languages = json.load(f)
# Access language data
finnish = languages.get("fin", {})
print(finnish.get("bcp47")) # fi-Latn-FI
# Get 10 nearest languages to Finnish
for neighbor in finnish.get("nearest_languages", [])[:10]:
print(f"{neighbor['lang']}: {neighbor['distance']:.4f}")uralic_languages.jsonmust be present for Uralic language support; the pipeline will issue a warning if missing.- The unified database integrates data from ISO, Wiktionary, CLDR, and POS statistics (Glottolog integration is currently referenced in codebase for future work).
- Fallback chains ensure robust language resolution for RSS feeds, locale matching, and software localization.
- The
nearest_languagesfield is computed using URIEL/lang2vec typological features (family, syntax, phonology, and inventory). - Distance scores range from
0.0(identical features) to1.0(completely different).
This project aggregates and unifies data from multiple linguistic databases:
- Glottolog: Comprehensive bibliographic data and genealogical classification for world languages. Hammarström, Harald & Forkel, Robert & Haspelmath, Martin & Bank, Sebastian. Glottolog. (glottolog.org)
- URIEL / lang2vec: Typological vector representations derived from URIEL knowledge base.
- ISO 639: Language code standards (ISO 639-1, 639-2, 639-3).
- CLDR / Wiktionary: Locale display names, scripts, and part-of-speech statistics.
This project is primary developed on Codeberg. Please submit issues, feature requests, and pull requests to the primary repository: https://codeberg.org/lahtis/GLFM
Copyright © 2026 Tuomas Lähteenmäki
This project is licensed under the MIT License. You may use, modify, and distribute the data, provided the original copyright notice is retained.
See LICENSE for details.