Datasets:
004 — Phylogenetic Metadata Enrichment
Date: 2026-03-14
Scope: Added phylo_pairs.tsv — phylogenetic relationship metadata for all language pairs, derived from Glottolog CLDF
1. Objective
Add phylogenetic metadata to the dataset so that downstream models can filter cognate pairs by evolutionary relationship (e.g., "train only on close sister pairs" or "exclude cross-family noise"). The existing cognate pairs have no phylogenetic information — they are flat (Lang_A, Lang_B) pairs with no tree context.
2. Scripts Used
| Script | Lines | Purpose |
|---|---|---|
scripts/ingest_glottolog.py |
~50 | Download Glottolog CLDF repo from GitHub |
scripts/build_glottolog_tree.py |
333 | Parse Glottolog NEXUS classification → build ancestry paths → output glottolog_tree.json |
scripts/build_phylo_pairs.py |
310 | Cross-reference cognate pair language pairs against tree → classify phylogenetic relationship → output phylo_pairs.tsv |
scripts/validate_phylo_pairs.py |
288 | Automated known-answer tests (14 cases), near-ancestral integrity, coverage audit, random pair audit |
3. Data Sources
| Source | Repository | License | Description |
|---|---|---|---|
| Glottolog CLDF v5.x | https://github.com/glottolog/glottolog-cldf |
CC BY 4.0 | Comprehensive language classification: 27,177 languoids, 8,184 with ISO 639-3 codes |
Files Used from Glottolog
cldf/languages.csv— 27,177 languoids with ISO 639-3 mapping, family assignment, Glottocodescldf/classification.nex— NEXUS format containing Newick trees for each language family
4. Source Reputability
Glottolog is the authoritative reference for language classification in computational linguistics:
- Maintainers: Harald Hammarström, Robert Forkel, Martin Haspelmath, Sebastian Bank (Max Planck Institute for Evolutionary Anthropology)
- Citation: Hammarström, H., Forkel, R., Haspelmath, M. & Bank, S. (2026). Glottolog 5.x. Leipzig: Max Planck Institute. DOI: 10.5281/zenodo.15640174
- Usage: Standard reference in all major computational historical linguistics publications
- Scope: Every known human language and dialect (8,000+ languages)
- Peer review: Continuously curated by professional linguists; corrections submitted via GitHub issues
5. Methodology
Step 1: Tree Construction (build_glottolog_tree.py)
- Parse NEXUS: Read
classification.nex, extract Newick strings per family tree - Parse Newick: Character-by-character parser handles nested parentheses, node labels, branch lengths (stripped — topological only)
- Build ancestry paths: BFS from root to each leaf, recording full path (e.g.,
["Indo-European", "Germanic", "West Germanic", "Anglic", "English"]) - Map ISO codes: Cross-reference
languages.csvto map ISO 639-3 → (Glottocode, family_id, ancestry_path) - Output:
glottolog_tree.json— JSON index mapping every ISO code to its tree position
Step 2: Phylogenetic Classification (build_phylo_pairs.py)
For each unique (Lang_A, Lang_B) pair in the cognate dataset:
- Look up ancestry paths for both languages in the tree index
- Compute MRCA (Most Recent Common Ancestor): Longest common prefix of the two ancestry paths
- Compute tree distance:
edges_A_to_MRCA + edges_B_to_MRCA - Classify relationship using this decision tree:
IF one or both languages not in tree:
→ "unclassified"
ELIF different top-level families:
→ "cross_family"
ELIF one language is in NEAR_ANCESTOR_MAP
AND the other's ancestry passes through the listed descendant clade
AND the other is NOT itself an ancient/medieval language:
→ "near_ancestral" (Ancestor_Lang = the ancient language)
ELIF MRCA_Depth >= 3:
→ "close_sister" (share a specific sub-branch)
ELSE:
→ "distant_sister" (share family or major branch only, depth 1-2)
Threshold: CLOSE_SISTER_DEPTH_THRESHOLD = 3 — chosen because depth 3 guarantees shared sub-branch classification (e.g., "West Germanic" under "Germanic" under "Indo-European"), while depth 1-2 captures only broad family membership.
Step 3: Near-Ancestral Curated Map
Why a curated map is necessary: Glottolog treats ALL attested languages as leaf nodes. Latin is classified as a sibling of Romance languages, not a parent. Without correction, Latin↔French would be classified as close_sister instead of near_ancestral.
Full curated map (19 entries):
| Ancestor | ISO | Descendant Clade (Glottocode) | Example Descendant |
|---|---|---|---|
| Latin | lat | roma1334 (Romance) | French, Spanish, Italian |
| Ancient Greek | grc | koin1234 (Koineic Greek) | Modern Greek |
| Sanskrit | san | indo1321 (Indo-Aryan) | Hindi, Bengali |
| Old English | ang | angl1265 (Anglic) | Modern English |
| Middle English | enm | angl1265 (Anglic) | Modern English |
| Old French | fro | oila1234 (Oïl French) | Modern French |
| Old Spanish | osp | cast1243 (Castilian) | Modern Spanish |
| Old Norse | non | nort3160 (North Germanic) | Swedish, Danish, Norwegian |
| Old High German | goh | high1289 (High German) | Modern German |
| Middle Dutch | dum | mode1257 (Modern Dutch) | Dutch, Afrikaans |
| Old Irish | sga | goid1240 (Goidelic) | Irish, Scottish Gaelic |
| Middle Irish | mga | goid1240 (Goidelic) | Irish, Scottish Gaelic |
| Old Church Slavonic | chu | sout3147 (South Slavic) | Bulgarian, Serbian |
| Old Russian | orv | east1426 (East Slavic) | Russian, Ukrainian |
| Old Chinese | och | clas1255 (Classical Chinese) | Mandarin, Cantonese |
| Ottoman Turkish | ota | oghu1243 (Oghuz) | Modern Turkish |
| Classical Arabic | arb-cla | arab1395 (Arabic) | Modern Arabic varieties |
| Middle Persian | pal | west2794 (Western Iranian) | Modern Persian |
| Old Japanese | ojp | japo1237 (Japonic) | Modern Japanese |
Justification: This map is small (19 entries), exhaustively verifiable by any linguist, and covers all well-attested ancestor-descendant relationships in the dataset. Each mapping follows the consensus in historical linguistics.
Output Schema (9 columns)
Lang_A | Lang_B | Phylo_Relation | Tree_Distance | MRCA_Clade |
MRCA_Depth | Ancestor_Lang | Family_A | Family_B
| Column | Type | Description |
|---|---|---|
Lang_A |
ISO 639-3 | First language (alphabetically ordered) |
Lang_B |
ISO 639-3 | Second language |
Phylo_Relation |
enum | near_ancestral, close_sister, distant_sister, cross_family, unclassified |
Tree_Distance |
int | Number of edges between the two languages via MRCA |
MRCA_Clade |
Glottocode | Glottocode of the most recent common ancestor node |
MRCA_Depth |
int | Depth of MRCA from tree root (root = 0) |
Ancestor_Lang |
ISO or - |
For near_ancestral: the ancestor language's ISO code. - otherwise |
Family_A |
string | Top-level family name for Lang_A |
Family_B |
string | Top-level family name for Lang_B |
Design Decision: Separate Lookup Table
The phylo metadata is stored as a separate phylo_pairs.tsv rather than as 7 additional columns on the 22.9M-row cognate_pairs_inherited.tsv. Rationale:
- 22.9M pairs reference only ~385K unique (Lang_A, Lang_B) combinations
- Adding 7 columns to 22.9M rows = 160M+ redundant cells
- Downstream join at query time: O(1) dict lookup by
(Lang_A, Lang_B)key - Keeps the cognate pairs file focused on linguistic data
6. Tests Performed
Automated Known-Answer Tests (14 cases in validate_phylo_pairs.py)
| Lang_A | Lang_B | Expected | Rationale |
|---|---|---|---|
| deu | eng | close_sister | Both West Germanic |
| eng | fra | distant_sister | Germanic vs Italic under IE |
| fra | lat | near_ancestral | Latin → Romance → French |
| lat | spa | near_ancestral | Latin → Romance → Spanish |
| lat | osc | distant_sister | Latino-Faliscan vs Sabellic |
| ang | eng | near_ancestral | Old English → Modern English |
| got | swe | distant_sister | East vs North Germanic |
| hin | san | near_ancestral | Sanskrit → Indo-Aryan → Hindi |
| eng | jpn | cross_family | IE vs Japonic |
| ceb | tgl | close_sister | Central Philippine |
| dan | swe | close_sister | North Germanic |
| ita | spa | close_sister | Italo-Western Romance |
| rus | ukr | close_sister | East Slavic |
| gle | sga | near_ancestral | Old Irish → Goidelic → Irish |
Result: All 14 tests PASS.
Coverage Audit
- ≥95% of ISO codes in the cognate dataset found in Glottolog tree index
- Unclassified pairs logged for manual review
Near-Ancestral Integrity
- Every
near_ancestralpair verified: ancestor is in curated map AND descendant's ancestry path passes through the specified clade
Random Pair Audit
- 20 random pairs selected, each verified:
- Family_A and Family_B match Glottolog's top-level classification
- MRCA_Depth and Tree_Distance consistent with ancestry paths
- Phylo_Relation follows the classification decision tree correctly
7. Cross-Referencing
- All tree positions cross-referenced against Glottolog online (https://glottolog.org/glottolog/language/[ISO])
- Known-answer pairs verified against published family trees in:
- Campbell, L. (2013). Historical Linguistics: An Introduction. MIT Press.
- Ringe, D. (2006). From Proto-Indo-European to Proto-Germanic. Oxford University Press.
- Near-ancestral relationships verified against standard reference grammars for each ancestor language
8. Output Summary
| File | Rows | Size |
|---|---|---|
data/training/metadata/phylo_pairs.tsv |
~386K | 24.7 MB |
data/training/raw/glottolog_cldf/glottolog_tree.json |
~8K entries | ~2 MB |
Relationship Distribution
| Relation | Count | % |
|---|---|---|
| close_sister | ~45% | Most pairs share a sub-branch |
| distant_sister | ~25% | Same family, different major branches |
| cross_family | ~20% | Different language families |
| near_ancestral | ~5% | Ancestor-descendant |
| unclassified | ~5% | One/both languages not in Glottolog |
9. Limitations (Phase 1)
- Topological only: No branch lengths (years of divergence). The Glottolog tree encodes relationships but not temporal distances.
- Phase 2 planned: Import Bayesian phylogenies from Phlorest (Chang et al. 2015, Bouckaert et al. 2012) to add
Divergence_Yearscolumn. - Near-ancestral map is manually curated: Only covers 19 well-attested ancestor-descendant pairs. Other potential ancestor-descendant relationships (e.g., within Austronesian) are classified as
close_sister.
10. Academic References
- Hammarström, H., Forkel, R., Haspelmath, M. & Bank, S. (2026). Glottolog 5.x. DOI: 10.5281/zenodo.15640174.
- Campbell, L. (2013). Historical Linguistics: An Introduction. 3rd ed. MIT Press.
- Ringe, D. (2006). From Proto-Indo-European to Proto-Germanic. Oxford University Press.
11. PRD Reference
Full specification: docs/prd/PRD_PHYLO_ENRICHMENT.md