langfamilysim
Estimate how similar languages are, three ways:
langfamilysim: genealogical similarity from Glottolog's classification tree, with a geographic-distance damped variant. Low-resource language in, closest related languages out.lwc: for a language, which languages of wider communication its speakers probably also speak (a directional bilingualism probability, e.g. Isanzu → Swahili), from Glottolog and Unicode CLDR data.biblesim: empirical similarity from verse-aligned Bibles in the eBible corpus, comparing words (Levenshtein), cognate rate, verse length and word order.
Requires Python 3.12+.
pip install langfamilysim
Quick start
Languages of wider communication (works out of the box)
from lwc.lookup import LWCLookup
lwc = LWCLookup()
for x in lwc.likely_lwcs("isn", k=3): # ISO 639-3 or glottocode
print(x.name, x.probability, x.country) # Swahili 0.9 TZ, English 0.69 TZ
Genealogical similarity (build the graph first)
The full graph (similarity.db, about 290 MB) is too large for PyPI, so you
build it from Glottolog. From a source checkout:
git clone https://github.com/TangoGroup/language-similarity.git
cd language-similarity/src/langfamilysim
./fetch_glottolog.sh # sparse clone of the Glottolog tree, under a minute
python3 build.py # writes nodes.csv, edges.csv, similarity.db (~20 s)
from similarity import LanguageSimilarity, name_lookup
names, iso_to_gc = name_lookup()
sim = LanguageSimilarity()
for other, score, kind in sim.top_related(iso_to_gc["spa"], k=10, by="combined"):
print(names[other], score, kind)
Each edge has a tree-based score and a combined score damped by
geographic distance (by="score" ignores geography). See
src/langfamilysim/README.md for the method.
Bible-based similarity
Download the eBible corpus separately (it is not included), then:
export BIBLESIM_CORPUS=/path/to/ebible/corpus
python -m biblesim compare spa por
python -m biblesim --stride 10 family indo1319 --langs spa,por,fra,ita,ron
python -m biblesim validate # Spearman correlation vs the Glottolog scores
Language families come from the similarity.db built above (--langdb).
See src/biblesim/README.md.
Data and licensing
The code is Apache-2.0. The data it ships or derives comes from third parties
under their own licenses: Glottolog and WALS (CC BY 4.0) and Unicode CLDR
(Unicode License). eBible translations are licensed individually, so check
each before redistributing any text. Details, credit lines and citations are in
DATA_SOURCES.md.
Geographic data is approximate: Glottolog gives one point per language, so distances are only a rough proxy for regional multilingualism.
Development
uv sync
uv run pytest
License
Metadata
Release files for langfamilysim 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langfamilysim-0.1.0.tar.gz | 1.2 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langfamilysim-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.4 MB
Release files / langfamilysim-0.1.0.tar.gz
| Download URL | langfamilysim-0.1.0.tar.gz |
|---|---|
| Size | 1.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
044f8154dbbde52d7a7e6eb6ab213126aeebb8a0dcb3ceb51c4f743a25384b43
|
|
BLAKE2b-256 checksum How to use checksums |
5132a6402d4dce5c0fbdeb41b33e2a6d72aa340f5019e66728a343bad4b4859a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / langfamilysim-0.1.0-py3-none-any.whl
| Download URL | langfamilysim-0.1.0-py3-none-any.whl |
|---|---|
| Size | 1.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6d4d39583f186f45657260b9749bfe6a9400542b9bc9fa2ed767bdf80776547
|
|
BLAKE2b-256 checksum How to use checksums |
7af56e77d830869e0b2aea47997774a51baada6a7c4e7cd4e33a37c0ac0d950e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|