# 003 — Cognate Pairs v2 Rebuild **Date**: 2026-03-13 **Scope**: Complete rebuild of all cognate pair files, fixing 6 critical pipeline bugs --- ## 1. Objective The original cognate pair extraction pipeline (v1) had 6 critical bugs that produced incorrect or incomplete data. This entry documents the complete rebuild from scratch using corrected v2 extraction scripts. ## 2. Bugs Fixed | # | Bug | Impact | Root Cause | |---|-----|--------|------------| | 1 | ABVD never read `cognates.csv` | 291K expert cognate judgements missing | Script read `forms.csv:Cognacy` column instead of the dedicated `cognates.csv` CognateTable | | 2 | Multi-set cognacy truncation | 37K lost set memberships | `Cognacy` field like `"1,2"` was truncated to `"1"` instead of splitting | | 3 | WOLD fabricated borrowing pairs | False borrowing relationships | Script generated pairs from concept co-occurrence instead of reading `borrowings.csv` donor-recipient table | | 4 | Concept-aligned pairs mislabeled as inherited | Inflated inherited count | Pairs from concept alignment (no expert cognacy) were labeled `expert_cognate` | | 5 | Sino-Tibetan Word field = Concept string | Wrong word forms | `Word_A`/`Word_B` contained concept labels, not actual word forms | | 6 | Alphabetical 50-entry hard truncation | Large families truncated | Families with >50 entries in a concept set had entries past the 50th alphabetically discarded | ## 3. Scripts Used | Script | Purpose | |--------|---------| | `scripts/extract_abvd_cognates_v2.py` | Read authoritative `cognates.csv` (291K entries), handle multi-set membership, include Doubt column | | `scripts/extract_wold_borrowings_v2.py` | Read authoritative `borrowings.csv` (21K donor-recipient events), extract Target_Form_ID + Source_Form_ID | | `scripts/extract_sinotibetan_cognates_v2.py` | Read `sinotibetan_dump.tsv` (6,159 entries with COGID), separate inherited vs borrowing by BORROWING column | | `scripts/extract_iecor_cognates.py` | Process IE-CoR CLDF CognateTable | | `scripts/extract_acd_cognates.py` | Process Austronesian Comparative Dictionary | | `scripts/merge_cognate_pairs.py` | Deduplicate across sources with priority ordering, produce 3 output files | ## 4. Data Sources Same 6 CLDF sources as 001, plus IE-CoR and ACD from 002. ## 5. Source Reputability - **ABVD `cognates.csv`**: 291,000 expert cognate judgements made by field linguists over 20+ years. Each entry has a `Doubt` column (certain/doubtful). This is the gold standard for Austronesian cognacy. - **WOLD `borrowings.csv`**: 21,000+ explicit donor→recipient borrowing events curated by 41 specialist authors. Each has a certainty score (1-5 scale). - **IE-CoR**: Expert cognate sets for Indo-European, curated by computational historical linguists at MPI-EVA. - All entries have `Source_Record_ID` for traceability back to original CLDF records. ## 6. Methodology ### 14-Column Output Schema ``` Lang_A | Word_A | IPA_A | Lang_B | Word_B | IPA_B | Concept_ID | Relationship | Score | Source | Relation_Detail | Donor_Language | Confidence | Source_Record_ID ``` ### Scoring - **SCA-weighted Levenshtein**: Normalized edit distance on Sound Class Alphabet (List 2012) encodings - Substitution cost: 0 for same class, 0.5 for similar classes (e.g., voiced↔voiceless stop), 1.0 for different classes - Gap penalty: 0.5 - Score = 1.0 − (normalized_distance), range [0.0, 1.0], rounded to 4 decimal places ### Deduplication Priority When the same (Lang_A, Lang_B, Concept_ID) tuple appears in multiple sources: 1. `expert_cognate` (priority 0) — keeps expert-labelled pair 2. `borrowing` (priority 1) 3. `concept_aligned` (priority 2) 4. `similarity_only` (priority 3) — lowest priority, only kept if no better evidence Pair key is order-independent: `min(side_a, side_b) || max(side_a, side_b) || concept` ### ABVD v2 Extraction (Bug #1 + #2 fix) - Reads `cognates.csv` (CLDF CognateTable), not `forms.csv:Cognacy` - Splits multi-set membership: `"1,2"` → entries in both cognateset 1 and 2 - Preserves `Doubt` column as `Confidence` field ### WOLD v2 Extraction (Bug #3 fix) - Reads `borrowings.csv` directly: each row = one donor→recipient event - Extracts `Target_Form_ID` and `Source_Form_ID`, resolves to language/word/IPA - No fabricated pairs — only explicit borrowing relationships ## 7. Tests Performed - All 406 existing tests pass after rebuild - `test_full_pipeline.py`: End-to-end Ugaritic-Hebrew cognate detection verified - `test_training_data.py`: Schema validation on all 3 output files - Row count verification against source repos: - ABVD: `wc -l cognates.csv` matches expected extraction count - WOLD: `wc -l borrowings.csv` matches expected extraction count - Deduplication audit: Verified no duplicate (Lang_A, Lang_B, Concept_ID) tuples in output ## 8. Cross-Referencing - 20 random inherited pairs traced back to ABVD `cognates.csv` by `Source_Record_ID` - 10 random borrowing pairs traced back to WOLD `borrowings.csv` by `Source_Record_ID` - Verified WOLD borrowing pairs have correct `Donor_Language` by cross-referencing with source - Verified Sino-Tibetan Word fields now contain actual word forms (not concept labels) ## 9. Output Summary | File | Rows | Size | Change from v1 | |------|------|------|-----------------| | `cognate_pairs_inherited.tsv` | 22.9M | 2.2 GB | +291K expert cognates recovered | | `cognate_pairs_borrowing.tsv` | 17K | 1.9 MB | Completely rebuilt (v1 was fabricated) | | `cognate_pairs_similarity.tsv` | 465K | 49.9 MB | Relabeled (was falsely `inherited` in v1) | ## 10. PRD Reference Full specification: `docs/prd/PRD_COGNATE_PAIRS_V2.md`