Global Language Family Mapper (GLFM)
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.6
Primary Links
- Canonical Repository (Codeberg):
https://codeberg.org/lahtis/GLFM - GitHub Mirror:
https://github.com/lahtis/GLFM
Features
- 7,900+ Languages: Unified from ISO 639-1/2/3/5, Wikidata (Glottolog), CLDR, 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.
- Checkpoint/Resume Support: Long-running nearest-language computations can be resumed automatically from a checkpoint.
Directory Structure
GLFM/
├── pyproject.toml
├── config.toml # Default configuration
├── README.md
├── LICENCE
├── output/ # Pipeline outputs (.gitignore)
│ ├── unified/ # unified_languages.json, languages_top20.json.gz
│ ├── validation/ # validation_report.md/html, errors
│ └── logs/
├── src/
│ └── glfm/
│ ├── __init__.py
│ ├── _version.py
│ ├── paths.py # Paths (cache, data, output)
│ ├── config.py # Configuration
│ ├── download.py # Data downloading
│ ├── build_unified.py # Unified database builder
│ ├── run_full_pipeline.py # Full pipeline
│ ├── data/ # Internal data (packaged)
│ │ ├── override_scripts.json
│ │ └── uralic_languages.json
│ ├── loaders/ # Data source loaders
│ ├── logic/ # Logic (script, region, fallback, BCP-47)
│ ├── models/ # Data models (Language)
│ └── tools/ # Validators, reports, helper scripts
└── venv/
Note: Downloadable data (
iso_639_*.py,glottolog.json,cldr/) lives in the cache (~/.cache/glfm/data/), not in the repo. Bundled data (override_scripts.json,uralic_languages.json) is shipped with the package (src/glfm/data/).
Data Structure (unified_languages.json)
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": "Finnic",
"glottocode": "finn1318",
"glottolog": {
"glottocode": "finn1318",
"iso639_3": "fin",
"family": "Finnic",
"macroarea": "",
"latitude": 62.0,
"longitude": 25.0,
"lineage": [ ],
"status": ""
},
"id": "fin",
"iso639_1": "fi",
"iso639_2B": "fin",
"iso639_2T": "fin",
"iso639_3": "fin",
"iso639_5": "",
"language_type": "L",
"name": "Finnish",
"nearest_languages": [
{
"lang": "est",
"distance": 0.0003
},
{
"lang": "izh",
"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 (up to 100 max_neighbors).language_typeis SIL Language Type (L = Living, E = Extinct, H = Historical, A = Ancient, C = Constructed).familyis Glottolog family name (e.g. "Finnic"), not an ISO 639-5 code.glottocodeis Glottolog language code (e.g. "finn1318").
Pipeline Overview
The pipeline is fully automated:
generate ISO → build glottolog → build unified → compute nearest → build consumer → validate → report → visualize
| Step | Module | Description |
|---|---|---|
| generate | glfm.tools.generate_iso_files |
Download ISO 639 sources |
| glottolog | glfm.tools.build_glottolog_json |
Fetch Glottolog metadata (Wikidata) |
| build | glfm.build_unified |
Build unified database |
| compute | glfm.tools.compute_nearest_languages |
Compute neighbors (lang2vec) |
| consumer | glfm.tools.build_consumer_dataset |
Build consumer dataset (top-20) |
| bcp47 | glfm.tools.validate_bcp47 |
Validate BCP-47 |
| fallbacks | glfm.tools.validate_fallbacks |
Validate fallbacks |
| iso | glfm.tools.validate_iso_consistency |
Validate ISO codes |
| pos | glfm.tools.validate_pos_stats |
Validate POS statistics |
| glotto | glfm.tools.validate_glottolog |
Validate Glottolog |
| report | glfm.tools.generate_report |
Generate reports |
| viz | glfm.tools.visualize_fallbacks |
Visualize fallbacks (optional) |
CLI
Full pipeline
python3 -m glfm.run_full_pipeline
Skip heavy neighbor computation
python3 -m glfm.run_full_pipeline --skip compute
Run only selected steps
python3 -m glfm.run_full_pipeline --only build bcp47
List steps
python3 -m glfm.run_full_pipeline --list
Configuration
config.toml (repo root) contains default values. Users can override:
~/.config/glfm/config.toml- Environment variables:
GLFM_DATA_DIR,GLFM_CACHE_DIR,GLFM_OUTPUT_DIR,GLFM_ISO_639_3_URL, etc.
Example:
[sources.iso_639_3]
url = "https://iso639-3.sil.org/sites/iso639-3/files/downloads/iso-639-3.tab"
[sources.cldr]
version = "48.0.0"
[sources.wikidata]
endpoint = "https://query.wikidata.org/sparql"
[paths]
data_dir = "" # empty = ~/.cache/glfm/data
cache_dir = "" # empty = ~/.cache/glfm
Quick Start
1 . Install
pip install glfm
2. Get data
Choose one of these:
Option A: Download pre-built data (recommended)
python3 -m glfm.download # consumer (558 kB)
python3 -m glfm.download --tier research # research (1.4 MB)
Option B: Generate data from sources (slow, requires network)
python3 -m glfm.run_full_pipeline --only generate glottolog
3 . Run the full pipeline
python3 -m glfm.run_full_pipeline
4 . Access data in Python
import gzip, json
from pathlib import Path
cache = Path.home() / ".cache" / "glfm" / "data"
with gzip.open(cache / "unified_languages.json.gz", "rt") as f:
languages = json.load(f)
fin = languages["fin"]
print(fin["bcp47"]) # fi-Latn-FI
print(fin["family"]) # Finnic
print(fin["glottocode"]) # finn1318
print(fin["nearest_languages"][:5]) # Top 5 nearest languages
4 . Consumer dataset (top-20 neighbors)
import gzip
import json
from pathlib import Path
# Option A: read from cache (after `glfm.download`)
cache = Path.home() / ".cache" / "glfm" / "data"
# Option B: read from pipeline output (after `glfm.run_full_pipeline`)
# output = Path("output/unified")
with gzip.open(cache / "languages_top20.json.gz", "rt") as f:
languages = json.load(f)
fin = languages["fin"]
print(f"bcp47: {fin['bcp47']}") # fi-Latn-FI
print(f"family: {fin['family']}") # Finnic
print(f"glottocode: {fin['glottocode']}") # finn1318
print(f"language_type: {fin['language_type']}") # L
print(f"neighbors: {len(fin['nearest_languages'])}") # 20
for nb in fin["nearest_languages"]:
print(f"{nb['lang']}: {nb['distance']:.4f}")
5. Research dataset (up to 100 neighbors)
import gzip
import json
from pathlib import Path
# Option A: read from cache (after `glfm.download --tier research`)
cache = Path.home() / ".cache" / "glfm" / "data"
# Option B: read from pipeline output (after `glfm.run_full_pipeline`)
# output = Path("output/unified")
with gzip.open(cache / "unified_languages.json.gz", "rt") as f:
languages = json.load(f)
fin = languages["fin"]
print(f"neighbors: {len(fin['nearest_languages'])}") # 100
for nb in fin["nearest_languages"]:
print(f"{nb['lang']}: {nb['distance']:.4f}")
Requirements
- Python 3.9+
- Core dependencies: none (pure stdlib)
- Dev dependencies:
numpy,requests,msgpack,lang2vec,graphviz,pytest
Installation
1. Create virtual environment
git clone https://codeberg.org/lahtis/GLFM.git
cd GLFM
python3 -m venv venv
source venv/bin/activate # Linux/macOS
# venv\Scripts\activate # Windows
2. Install package
pip install glfm
3. Install development dependencies (optional)
pip install -e ".[dev]"
or
git clone https://codeberg.org/lahtis/GLFM.git
cd GLFM
python3 -m venv venv
source venv/bin/activate
pip install -e .
Data Sources & Acknowledgments
- Glottolog: Hammarström, Harald & Forkel, Robert & Haspelmath, Martin & Bank, Sebastian. Glottolog. (glottolog.org) – fetched via Wikidata SPARQL.
- URIEL / lang2vec: Typological vector representations.
- ISO 639: Language code standards (ISO 639-1, 639-2, 639-3, 639-5).
- CLDR / Wiktionary: Locale display names, scripts.
Contributing & Issues
https://codeberg.org/lahtis/GLFM
License
Copyright © 2026 Tuomas Lähteenmäki
MIT License. See LICENSE for details.
Key changes
| # | Section | Change |
|---|---|---|
| 1 | Python version | 3.8+ → 3.9+ |
| 2 | Directory Structure | src/glfm/ layout |
| 3 | Data Structure | family: "Finnic", glottocode: "finn1318", language_type: "L" |
| 4 | nearest_languages |
5 → 100 (max) |
| 5 | Pipeline Overview | 12 steps (incl. glottolog, consumer) |
| 6 | CLI | python3 -m glfm.run_full_pipeline |
| 7 | Configuration | config.toml + env vars |
| 8 | Requirements | No core dependencies (pure stdlib) |
| 9 | build_top5.py |
build_consumer_dataset.py |
| 10 | "Glottolog future work" | Glottolog works (Wikidata) |
Metadata
Release files for glfm 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| glfm-1.0.6.tar.gz | 51.0 kB | Without provenance | Details for glfm-1.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| glfm-1.0.6-py3-none-any.whl | Python 3 | none | any | Details for glfm-1.0.6-py3-none-any.whl |
Total release size: 128.1 kB
Release files / glfm-1.0.6.tar.gz
| Download URL | glfm-1.0.6.tar.gz |
|---|---|
| Size | 51.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2fa15683648b7e3489833e5da42abfa4768476744d138fd55743f74e6646ea71
|
|
BLAKE2b-256 checksum How to use checksums |
0a12eccaeaea041489dbb513bfe5fdc2d264831a0c3ceb42c83b012e4adfffda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / glfm-1.0.6-py3-none-any.whl
| Download URL | glfm-1.0.6-py3-none-any.whl |
|---|---|
| Size | 77.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
25e7f46523c440fabc5dd16c9eaae4b436166013a3795b3e77cbb8ffe6cd2305
|
|
BLAKE2b-256 checksum How to use checksums |
935196e31ee85348a1c76b53a9ecc751a59da05e2e26baadd7e163cf3c14484f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for glfm 1.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.