{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# World Languages - Interactive Demo\n",
"\n",
"Explore **7,130 world languages** with geographic coordinates, speaker populations, and language family classification.\n",
"\n",
"**Dataset Highlights:**\n",
"- Geographic coordinates for mapping\n",
"- Speaker population estimates\n",
"- Language family classification (Glottolog)\n",
"- Bible translation status (Joshua Project)\n",
"- ISO 639-3 codes as primary keys"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Uncomment to install dependencies\n",
"# !pip install pandas matplotlib seaborn folium"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import pandas as pd\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns\n",
"from collections import Counter\n",
"import warnings\n",
"warnings.filterwarnings('ignore')\n",
"\n",
"plt.style.use('seaborn-v0_8-darkgrid')\n",
"sns.set_palette('husl')\n",
"\n",
"print('Libraries loaded')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Load Dataset"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"with open('world_languages_integrated.json') as f:\n",
" data = json.load(f)\n",
"\n",
"print(f'Total languages: {len(data):,}')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Flatten the nested structure for analysis\n",
"records = []\n",
"for lang in data:\n",
" record = {\n",
" 'iso_639_3': lang.get('iso_639_3'),\n",
" 'name': lang.get('name'),\n",
" 'family': lang.get('glottolog', {}).get('family_name', 'Unknown'),\n",
" 'macroarea': lang.get('glottolog', {}).get('macroarea', 'Unknown'),\n",
" 'latitude': lang.get('glottolog', {}).get('latitude'),\n",
" 'longitude': lang.get('glottolog', {}).get('longitude'),\n",
" 'glottocode': lang.get('glottolog', {}).get('glottocode'),\n",
" 'speakers': lang.get('speaker_count', {}).get('count') if lang.get('speaker_count') else None,\n",
" 'religion': lang.get('joshua_project', {}).get('primary_religion', ''),\n",
" 'bible_status': lang.get('joshua_project', {}).get('bible_status', 0),\n",
" }\n",
" records.append(record)\n",
"\n",
"df = pd.DataFrame(records)\n",
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. Dataset Overview"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print('Dataset Overview:')\n",
"print('=' * 50)\n",
"print(f'Total languages: {len(df):,}')\n",
"print(f'With coordinates: {df[\"latitude\"].notna().sum():,} ({df[\"latitude\"].notna().sum()/len(df)*100:.1f}%)')\n",
"print(f'With speaker counts: {df[\"speakers\"].notna().sum():,} ({df[\"speakers\"].notna().sum()/len(df)*100:.1f}%)')\n",
"print(f'Unique families: {df[\"family\"].nunique()}')\n",
"print(f'Unique macroareas: {df[\"macroarea\"].nunique()}')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3. Language Family Distribution"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Top 15 language families\n",
"family_counts = df['family'].value_counts().head(15)\n",
"\n",
"print('Top 15 Language Families:')\n",
"print('=' * 50)\n",
"for family, count in family_counts.items():\n",
" pct = count / len(df) * 100\n",
" bar = '|' * int(pct)\n",
" print(f'{family:30s} {count:5,} ({pct:5.1f}%) {bar}')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig, ax = plt.subplots(figsize=(12, 8))\n",
"family_counts.plot(kind='barh', ax=ax, color='steelblue')\n",
"ax.set_xlabel('Number of Languages', fontsize=12)\n",
"ax.set_ylabel('Language Family', fontsize=12)\n",
"ax.set_title('Top 15 Language Families', fontsize=14, fontweight='bold')\n",
"ax.grid(axis='x', alpha=0.3)\n",
"plt.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4. Geographic Distribution"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Macroarea distribution\n",
"macroarea_counts = df['macroarea'].value_counts()\n",
"\n",
"print('Languages by Macroarea:')\n",
"print('=' * 50)\n",
"for area, count in macroarea_counts.items():\n",
" pct = count / len(df) * 100\n",
" print(f'{area:20s} {count:5,} ({pct:5.1f}%)')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Plot languages on world map\n",
"valid_coords = df[df['latitude'].notna() & df['longitude'].notna()]\n",
"\n",
"fig, ax = plt.subplots(figsize=(16, 8))\n",
"scatter = ax.scatter(\n",
" valid_coords['longitude'],\n",
" valid_coords['latitude'],\n",
" c=pd.factorize(valid_coords['macroarea'])[0],\n",
" alpha=0.5,\n",
" s=5,\n",
" cmap='tab10'\n",
")\n",
"ax.set_xlabel('Longitude', fontsize=12)\n",
"ax.set_ylabel('Latitude', fontsize=12)\n",
"ax.set_title('Global Distribution of Languages', fontsize=14, fontweight='bold')\n",
"ax.grid(alpha=0.3)\n",
"plt.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 5. Speaker Populations"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Top 20 languages by speakers\n",
"with_speakers = df[df['speakers'].notna()].copy()\n",
"top_speakers = with_speakers.nlargest(20, 'speakers')[['name', 'family', 'speakers']]\n",
"\n",
"print('Top 20 Languages by Speaker Count:')\n",
"print('=' * 60)\n",
"for idx, row in top_speakers.iterrows():\n",
" speakers_m = row['speakers'] / 1_000_000\n",
" print(f\"{row['name']:25s} {row['family']:25s} {speakers_m:8.1f}M\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Speaker distribution (log scale)\n",
"fig, ax = plt.subplots(figsize=(12, 6))\n",
"with_speakers['speakers'].apply(np.log10).hist(bins=50, ax=ax, color='teal', edgecolor='white')\n",
"ax.set_xlabel('Speakers (log10 scale)', fontsize=12)\n",
"ax.set_ylabel('Number of Languages', fontsize=12)\n",
"ax.set_title('Distribution of Speaker Populations', fontsize=14, fontweight='bold')\n",
"ax.set_xticks([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n",
"ax.set_xticklabels(['1', '10', '100', '1K', '10K', '100K', '1M', '10M', '100M', '1B'])\n",
"plt.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 6. Bible Translation Status"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Bible translation status\n",
"bible_labels = {\n",
" 0: 'Unspecified',\n",
" 1: 'Translation Needed',\n",
" 2: 'Translation Started',\n",
" 3: 'Portions Available',\n",
" 4: 'New Testament',\n",
" 5: 'Complete Bible'\n",
"}\n",
"\n",
"df['bible_label'] = df['bible_status'].map(bible_labels)\n",
"bible_counts = df['bible_label'].value_counts()\n",
"\n",
"print('Bible Translation Status:')\n",
"print('=' * 50)\n",
"for status, count in bible_counts.items():\n",
" pct = count / len(df) * 100\n",
" print(f'{status:25s} {count:5,} ({pct:5.1f}%)')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 7. Interactive Map"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import folium\n",
"from folium.plugins import MarkerCluster\n",
"\n",
"# Sample for performance\n",
"sample = valid_coords.sample(min(1000, len(valid_coords)))\n",
"\n",
"m = folium.Map(location=[20, 0], zoom_start=2, tiles='CartoDB positron')\n",
"marker_cluster = MarkerCluster().add_to(m)\n",
"\n",
"for idx, row in sample.iterrows():\n",
" popup = f\"{row['name']}
Family: {row['family']}
Macroarea: {row['macroarea']}\"\n",
" folium.CircleMarker(\n",
" location=[row['latitude'], row['longitude']],\n",
" radius=4,\n",
" popup=popup,\n",
" color='steelblue',\n",
" fill=True,\n",
" fillOpacity=0.6\n",
" ).add_to(marker_cluster)\n",
"\n",
"m.save('languages_map.html')\n",
"print('Map saved to languages_map.html')\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 8. Query Examples"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Find all Indo-European languages\n",
"indo_european = df[df['family'] == 'Indo-European']\n",
"print(f'Indo-European languages: {len(indo_european):,}')\n",
"print(indo_european[['name', 'macroarea', 'speakers']].head(10))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Find endangered languages (small speaker populations)\n",
"endangered = df[(df['speakers'].notna()) & (df['speakers'] < 1000)]\n",
"print(f'Languages with <1000 speakers: {len(endangered):,}')\n",
"print(endangered[['name', 'family', 'speakers']].head(10))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Languages in Africa\n",
"africa = df[df['macroarea'] == 'Africa']\n",
"africa_families = africa['family'].value_counts().head(10)\n",
"print(f'Languages in Africa: {len(africa):,}')\n",
"print('\\nTop families in Africa:')\n",
"print(africa_families)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Conclusion\n",
"\n",
"This notebook demonstrated:\n",
"\n",
"- Loading and exploring 7,130 world languages\n",
"- Analyzing language family distributions\n",
"- Mapping geographic distributions\n",
"- Exploring speaker populations\n",
"- Querying by region and attributes\n",
"\n",
"**Author**: Luke Steuber | luke@lukesteuber.com | @lukesteuber.com (Bluesky)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.10.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}