Last active
April 24, 2025 16:16
-
-
Save cavedave/fc8c73e2c09be90ddf78434345a91932 to your computer and use it in GitHub Desktop.
Turkey in European languages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abk grey | |
sqi sea rooster pink | |
ara bibi tan | |
hye grey | |
de-at yellow | |
eus indian yellow | |
bel indian yellow | |
bos ćùrān tan | |
bre lightblue | |
bul swanky bird blue | |
cat indian yellow | |
cor guinea skyblue | |
hrv ćùrān tan | |
ces krocan tan | |
dan calicut orange | |
nld calicut orange | |
eng turkey green | |
est calicut orange | |
fao calicut orange | |
fin calicut orange | |
vls skyblue | |
fra indian yellow | |
gag | |
sar | |
glg peru lightblue | |
kat salmon | |
deu pute tan | |
ell indian yellow | |
hun pulyka tan | |
isl calicut orange | |
gle turkey green | |
ita tacchino tan | |
kaz grey | |
lav turkey green | |
lig bibìn tan | |
lit calicut orange | |
ltz snot hen palevioletred | |
mkd egypt salmon | |
mlt indian yellow | |
nap gallarinio tan | |
sme calicut orange | |
nor calicut orange | |
occ piòt tan | |
pms grey | |
pol indian yellow | |
por peru lightblue | |
ron hen palevioletred | |
roh indian yellow | |
rus indian yellow | |
srd indian yellow | |
sco bubbly-jock green | |
gla french rooster lightgreen | |
srp ćùrān tan | |
sic tacchinu tan | |
slk sea child lightgreen | |
slv peru lightblue | |
spa peacock blue | |
swe calicut orange | |
tur indian yellow | |
ukr indian yellow | |
ven piton tan | |
cym turkey green | |
fry calicut orange | |
glv french rooster lightgreen | |
tat lightgreen | |
xal lightgreen | |
oss lightgreen | |
aze lightgreen | |
krl calicut orange |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
generateMap.py: Python 3 compatible script to generate etymology maps. | |
Usage: python3 generateMap.py path/to/dictionary_[word].txt | |
Produces: map_[word].svg in the same directory, cropped on the east side and annotated with a legend. | |
""" | |
import sys | |
import os | |
import re | |
import xml.etree.ElementTree as ET | |
# original colors in template keyed by language code | |
language_color_pairs = [ | |
('abk', '168d4f'), ('ara', 'ffffb1'), ('aze', 'd45500'), ('bel', 'b5ff64'), | |
('bos', 'abc837'), ('bre', '178df0'), ('bul', '36ae22'), ('cat', '00ffff'), | |
('cau', 'd38d5f'), ('ces', '00cb60'), ('cor', 'c0003c'), ('cym', 'ff7f29'), | |
('dan', 'ff5555'), ('deu', 'd09999'), ('ell', 'ffff00'), ('eng', 'ffaaaa'), | |
('est', 'b7c8be'), ('eus', 'ffd42a'), ('fao', 'ff0000'), ('fin', '6f997a'), | |
('fra', '53bbb5'), ('fry', 'd66c74'), ('gag', 'c837ab'), ('gla', 'ff7f2a'), | |
('gle', 'fd6d3c'), ('glg', '00d4aa'), ('hrv', '00d4d4'), ('hun', 'ac9d93'), | |
('hye', '008080'), ('isl', 'f19076'), ('ita', '7bafe0'), ('kat', 'f4e3d7'), | |
('kaz', 'deaa87'), ('krl', '93ac93'), ('lav', 'de87cd'), ('lit', 'e9afdd'), | |
('lig', 'f2003c'), ('ltz', '55ddff'), ('mkd', '71c837'), ('mlt', 'a0892c'), | |
('nap', 'f5003c'), ('nld', 'f4d7d7'), ('nor', 'ff8080'), ('occ', '168d5f'), | |
('oss', '985fd3'), ('pms', 'f2d53c'), ('pol', '7ecb60'), ('por', '00d4d4'), | |
('roh', '008079'), ('ron', 'aaccff'), ('rus', '72ff00'), ('sar', 'c0ee3c'), | |
('sco', '168df0'), ('sic', 'cc003c'), ('slk', '42f460'), ('slv', '81c98d'), | |
('sme', 'cccccc'), ('spa', 'acd8ed'), ('sqi', 'a0856c'), ('srp', 'abc837'), | |
('swe', 'ffb380'), ('tat', 'c7a25f'), ('tur', 'cc9e4c'), ('ven', 'f28d3c'), | |
('xal', 'd34d5f'), ('ukr', 'c1ff00') | |
] | |
language_codes, template_colors = zip(*language_color_pairs) | |
# mapping of English color names to hex (extended for legend) | |
english_to_hex = { | |
'turquoise': '#8dd3c7', 'yellow': '#ffffb3', 'purple': '#bebada', | |
'red': '#fb8072', 'blue': '#80b1d3', 'orange': '#fdb462', | |
'green': '#b3de69', 'pink': '#fccde5', 'grey': '#d9d9d9', | |
'white': '#ffffff', 'darkgrey': '#999999', 'lightblue': '#ADD8E6', 'tan': '#D2B48C' | |
} | |
# legend definition: (color_name, label) | |
legend_items = [ | |
('tan', 'Onomatopoeia: word based on birds sound'), | |
('orange', 'Calcut: Indian port city'), | |
('green', 'Turkey: imported by Turkish traders'), | |
('yellow', 'Indian they thought came from India') | |
] | |
def load_template(): | |
template_path = os.path.join(os.path.dirname(__file__), 'resources', 'europe_template.svg') | |
if not os.path.isfile(template_path): | |
raise FileNotFoundError(f"Template not found: {template_path}") | |
with open(template_path, 'r', encoding='utf-8') as f: | |
return f.read() | |
def parse_dictionary(path): | |
lang_list, word_list, col_list = [], [], [] | |
with open(path, 'r', encoding='utf-8') as f: | |
for line in f: | |
line = line.rstrip('\n') | |
if not line: | |
continue | |
parts = line.split('\t', 2) | |
lang = parts[0] | |
raw_word = parts[1].strip() if len(parts) > 1 else '' | |
word = re.sub(r'^"+|"+$', '', raw_word).strip() | |
raw_col = parts[2].strip() if len(parts) > 2 and parts[2].strip() else 'grey' | |
col = english_to_hex.get(raw_col, raw_col) | |
lang_list.append(lang) | |
word_list.append(word) | |
col_list.append(col) | |
return lang_list, word_list, col_list | |
def add_legend(svg_source): | |
# construct legend SVG snippet (positioned lower in the map) | |
# translate(y) adjusted to 400px down from top; tweak as needed | |
lines = ['<g id="legend" transform="translate(10,100)">'] | |
# title | |
lines.append(' <text x="0" y="0" font-size="20" font-weight="bold">Turkey Etymology (bird only native too North America)</text>') | |
for i, (col_name, label) in enumerate(legend_items): | |
color_hex = english_to_hex.get(col_name, col_name) | |
y = 20 + i * 20 # start items 20px below title | |
lines.append(f' <rect x="0" y="{y}" width="15" height="15" fill="{color_hex}" />') | |
lines.append(f' <text x="20" y="{y+12}" font-size="18">{label}</text>') | |
lines.append('</g>') | |
snippet = '\n '.join(lines) | |
return svg_source.replace('</svg>', f' {snippet}\n</svg>') | |
def main(): | |
if len(sys.argv) != 2: | |
print("Usage: python3 generateMap.py path/to/dictionary_[word].txt") | |
sys.exit(1) | |
input_file = sys.argv[1] | |
output_file = os.path.basename(input_file).replace('dictionary', 'map').replace('.txt', '.svg') | |
try: | |
svg_source = load_template() | |
except FileNotFoundError as e: | |
print(e) | |
sys.exit(1) | |
lang_list, word_list, col_list = parse_dictionary(input_file) | |
for lang, word, col in zip(lang_list, word_list, col_list): | |
svg_source = svg_source.replace(f'${lang}', word) | |
try: | |
orig_col = template_colors[language_codes.index(lang)] | |
svg_source = svg_source.replace(f'#{orig_col}', col) | |
except ValueError: | |
print(f"Warning: {lang} not found in template language list.") | |
# Insert legend before writing | |
svg_source = add_legend(svg_source) | |
# Write the new SVG | |
with open(output_file, 'w', encoding='utf-8') as f: | |
f.write(svg_source) | |
print(f"Generated map: {output_file}") | |
# Adjust viewBox to crop the east side | |
try: | |
tree = ET.parse(output_file) | |
root = tree.getroot() | |
vb = root.get('viewBox') | |
if vb: | |
x, y, w, h = map(float, vb.split()) | |
new_w = 1060.0 | |
root.set('viewBox', f"{x} {y} {new_w} {h}") | |
if root.get('width'): | |
root.set('width', str(new_w)) | |
tree.write(output_file, encoding='utf-8') | |
print("ViewBox cropped successfully.") | |
except Exception as e: | |
print("Warning: could not crop viewBox:", e) | |
if __name__ == '__main__': | |
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lang,iso,word,translation,meaning_group,color,source | |
Abkhaz,abk,,,,grey, | |
Albanian,sqi,gjeli i detit,saltwater rooster,,salmon,https://en.wiktionary.org/wiki/turkey | |
Arabic,ara,بيبي,bibi,Onomatopoeia,tan,https://en.wiktionary.org/wiki/%D8%A8%D9%8A%D8%A8%D9%8A#Moroccan_Arabic | |
Armenian,hye,,,,grey, | |
Austrian German,de-at,,,,lemonchiffon, | |
Azerbaijani,aze,,,from_calicut,orange, | |
Bashkir,bak,күркә ,,from_calicut,orange, | |
Basque,eus, indioilar ,indian,from_india,lemonchiffon, | |
Belarusian,bel,дзі́кая інды́чка ,Indian,from_india,lemonchiffon,https://en.wiktionary.org/wiki/turkey | |
Bosnian,bos,ćùrān,ćùrān ,Onomatopoeia,tan, | |
Breton,bre, kilhog-Indez,,,lightblue, | |
Bulgarian,bul, пуйка,swanky bird,Funny,blue,https://en.wiktionary.org/wiki/%D0%BF%D1%83%D0%B9%D0%BA%D0%B0#Bulgarian | |
Catalan,cat,gall dindi ,Indian,from_india,lemonchiffon, | |
Cornish,cor,yar Gyni ,Guinea,,skyblue, | |
Croatian,hrv,ćùrān,ćùrān ,Onomatopoeia,tan, | |
Czech,ces,krocan,krocan,Onomatopoeia,tan, | |
Danish,dan,kalkun,calcuta,from_calicut,orange, | |
Dutch,nld,kalkoen,calcuta,from_calicut,orange, | |
English,eng,Turkey,Turkey,Turkey,green, | |
Estonian,est,kalkun,calcuta,from_calicut,orange, | |
Faroese,fao,kalkun,calcuta,from_calicut,orange, | |
Finnish,fin,kalkkuna,calcuta,from_calicut,orange, | |
Flemish (Belgium),vls,,,,skyblue, | |
French,fra,dinde ,Indian,from_india,lemonchiffon, | |
Gagauz,gag,,,from_calicut,orange, | |
Galician,glg, pavo,Peru,from_peru,green, | |
Georgian,kat,,,,salmon, | |
German,deu,Pute,Pute,Onomatopoeia,tan,https://en.wiktionary.org/wiki/Pute#German | |
Greek,ell,γαλοπούλα,Indian,from_india,lemonchiffon, | |
Hungarian,hun,pulyka,pulyka,Onomatopoeia,tan, | |
Icelandic,isl,kalkúnn,calcuta,from_calicut,orange, | |
Irish,gle ,turcaí ,Turkey,Turkey,green, | |
Italian,ita,tacchino,tacchino,Onomatopoeia,tan, | |
Kazakh,kaz,,,,grey, | |
Latvian,lav,tītars ,Turkey,Turkey,green, | |
Ligurian,lig,bibìn ,bibìn ,Onomatopoeia,tan, | |
Lithuanian,lit,kalakùtas ,calcuta,from_calicut,orange, | |
Luxembourgish,ltz,schnuddelhong,snot hen,,lemonchiffon, | |
Macedonian,mkd,мисирка,egypt,,salmon, | |
Maltese,mlt,dundjan,Indian,from_india,lemonchiffon,https://en.wiktionary.org/wiki/dundjan#Maltese | |
Neapolitan,nap,gallarinio,gallarinio,Onomatopoeia,tan,https://en.wiktionary.org/wiki/pinto#Neapolitan | |
Northern Sami,sme,kálkon,calcuta,from_calicut,orange, | |
Norwegian,nor,kalkun,calcuta,from_calicut,orange, | |
Occitan,occ,piòt,piòt,Onomatopoeia,tan, | |
Piedmontese,pms,,,,grey, | |
Polish,pol,indyk ,Indian,from_india,lemonchiffon, | |
Portuguese,por, peru,Peru,from_peru,green, | |
Romanian,ron,curcan,Hen,,palevioletred, | |
Romansh,roh,galdin ,Indian,from_india,lemonchiffon, | |
Russian,rus,индю́к,Indian,from_india,lemonchiffon, | |
Sardinian,srd,dindu ,Indian,from_india,lemonchiffon, | |
Scots,sco,bubbly-jock,bubbly-jock,,green, | |
Scottish Gaelic,gla,coileach-Frangach,French rooster,from_france,lightgreen, | |
Serbian,srp,ćùrān ,ćùrān ,Onomatopoeia,tan,https://en.wiktionary.org/wiki/%C4%87uran#Serbo-Croatian | |
Sicilian,sic,tacchinu,tacchinu,Onomatopoeia,tan, | |
Slovak,slk,moriak,Sea child,,lightgreen,https://en.wiktionary.org/wiki/Reconstruction:Proto-Slavic/mo%C5%99ak%D1%8A | |
Slovene,slv,puran,Peru,from_peru,green, | |
Spanish,spa,pavo,Peacock,,lightblue, | |
Swedish,swe, kalkon,calcuta,from_calicut,orange, | |
Turkish,tur,hindi,Indian,from_india,lemonchiffon, | |
Ukrainian,ukr,інди́к,Indian,from_india,lemonchiffon, | |
Venetian,ven,piton ,piton ,Onomatopoeia,tan, | |
Welsh,cym,twrci,Turkey,Turkey,green, | |
West Frisian,fry,kalkoen,calcuta,from_calicut,orange, | |
Manx,glv,kellagh frangagh,French rooster,from_france,lightgreen, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment