def gradation_make_morphophonemes(wordmap): '''mark up gradating stop for morphophonological handling''' if not wordmap['kotus_tn']: return wordmap tn = wordmap['kotus_tn'] av = wordmap['kotus_av'] if not wordmap['kotus_av']: return wordmap if tn in range(1, 28) or tn in range(29, 32) or tn in range(52, 66) or tn == 76 or tn in [1009, 1010]: # strong root stem if av == 'A': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'k', '{k~~}') elif av == 'B': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'p', '{p~~}') elif av == 'C': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 't', '{t~~}') elif av == 'D': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'k', '{k~~}') elif av == 'E': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'p', '{p~~}') elif av == 'F': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 't', '{t~~}') elif av == 'G': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'k', '{k~~}') elif av == 'H': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'p', '{p~~}') elif av == 'I': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 't', '{t~~}') elif av == 'J': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 't', '{t~~}') elif av == 'K': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 't', '{t~~}') elif av == 'L': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'k', '{k~~}') elif av == 'M': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'k', '{k~~}') elif av == 'O': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'g', '{g~~}') elif av == 'P': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'b', '{b~~}') elif av == 'N': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'd', '{d~~}') else: print("unhandled gradation in", wordmap, file=stderr) return None return wordmap elif tn == 28: # gah gradation in stemparts return wordmap elif tn == 1007: # not gradation return wordmap else: # weak root stem if av == 'A': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'k', 'k{k~~}') elif av == 'B': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'p', 'p{p~~}') elif av == 'C' and tn in range(72, 76): # TVtA verbs wordmap['gradestem'] = wordmap['gradestem'][:wordmap['gradestem'].rfind('t')- 2 ] + 't{t~~}' + wordmap['gradestem'][wordmap['gradestem'].rfind('t')-1:] elif av == 'C': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 't', 't{t~~}') elif av == 'D': # danger ahead! (it appears from middle of nowhere) if tn == 32: wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'e', '{k~~}e') elif tn == 33: wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'i', '{k~~}i') elif tn == 41: wordmap['gradestem'] = replace_rightmosts(wordmap['gradestem'], ['as', 'es', 'is', '{aä}s'], ['{k~~}as', '{k~0}es', '{k~0}is', '{k~~}{aä}s']) elif tn == 43: wordmap['gradestem'] = replace_rightmosts(wordmap['gradestem'], ['ut', 'yt'], ['{k~~}ut', '{k~~}yt']) elif tn == 44: wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'e', '{k~~}e') elif tn == 48: wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'e', '{k~~}e') elif tn == 49: wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'en', '{k~~}en') elif tn == 67: wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'ell', '{k~~}ell') elif tn == 72: wordmap['gradestem'] = replace_rightmosts(wordmap['gradestem'], ['at', 'et', 'ot'], ['{k~~}at', '{k~~}et', '{k~0}ot']) elif tn == 73: wordmap['gradestem'] = replace_rightmosts(wordmap['gradestem'], ['ata', 'ätä'], ['{k~~}ata', '{k~0}ätä']) elif tn == 74: wordmap['gradestem'] = replace_rightmosts(wordmap['gradestem'], ['ota', 'eta', 'ötä', 'etä'], ['{k~~}ota', '{k~0}eta', '{k~0}ötä', '{k~0}etä']) elif tn == 75: wordmap['gradestem'] = replace_rightmosts(wordmap['gradestem'], ['ita', 'itä'], ['{k~~}ita', '{k~0}itä']) elif tn == 99: pass else: print("Unhandled D weak", wordmap['gradestem'], tn, file=stderr) elif av == 'E': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'v', '{p~~}') elif av == 'F': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'd', '{t~~}') elif av == 'G': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'g', '{k~~}') elif av == 'H': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'm', '{p~~}') elif av == 'I' and tn != 67: wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'l', '{t~~}') elif av == 'I' and tn == 67: wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'lell', '{t~~}ell') elif av == 'J' and tn != 33: wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'n', '{t~~}') elif av == 'J' and tn == 33: wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'nin', '{t~~}in') elif av == 'K': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'r', '{t~~}') elif av == 'L': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'j', '{k~~}') elif av == 'N': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'd', 'd{d~~}') elif av == 'O': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'g', 'g{g~~}') elif av == 'P': wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'b', 'b{b~~}') elif av == 'T' and tn == 49: wordmap['gradestem'] = replace_rightmost(wordmap['gradestem'], 'e', '{t~~}e') else: print("unhandled gradation in", wordmap, file=stderr) return None return wordmap return None
def plurale_tantum_get_singular_stem(wordmap): """Guess inflectional singulars for words whose dictionary form is plural. """ if not wordmap["kotus_tn"]: return wordmap tn = int(wordmap["kotus_tn"]) av = wordmap["kotus_av"] if not wordmap["plurale_tantum"] == "obligatory": return wordmap if wordmap["kotus_av"] and tn not in [27, 28, 34]: if tn in [7, 23, 24, 25, 26, 29, 30]: wordmap["stub"] = replace_rightmost(wordmap["stub"], "e", "i") # ^^ generic extra tweak if (tn in range(1, 7) or tn in range(8, 16) or tn in range(17, 22)) and wordmap["kotus_av"] == "A": wordmap["stub"] = replace_rightmost(replace_rightmost(wordmap["stub"], "t", ""), "k", "kk") elif (tn in range(1, 7) or tn in range(8, 16) or tn in range(17, 22)) and wordmap["kotus_av"] == "B": wordmap["stub"] = replace_rightmost(replace_rightmost(wordmap["stub"], "t", ""), "p", "pp") elif (tn in range(1, 7) or tn in range(8, 16) or tn in range(17, 22)) and wordmap["kotus_av"] == "C": wordmap["stub"] = replace_rightmost(replace_rightmost(wordmap["stub"], "t", ""), "t", "tt") elif tn == 1 and wordmap["kotus_av"] == "D": wordmap["stub"] = replace_rightmosts(wordmap["stub"], ["ut", "yt", "öt", "ot"], ["ku", "ky", "kö", "ko"]) elif tn in [5, 7] and wordmap["kotus_av"] == "D": wordmap["stub"] = replace_rightmost(wordmap["stub"], "it", "ki") elif tn in [9, 10] and wordmap["kotus_av"] == "D": wordmap["stub"] = replace_rightmosts(wordmap["stub"], ["at", "ät"], ["ka", "kä"]) elif tn == 1007: wordmap["stub"] = replace_rightmost(wordmap["stub"], "jet", "i") elif tn in [1009, 1010] and wordmap["kotus_av"] == "D": wordmap["stub"] = replace_rightmost(wordmap["stub"], "jat", "ika") elif tn == 32 and wordmap["kotus_av"] == "C": wordmap["stub"] = replace_rightmost(replace_rightmost(wordmap["stub"], "et", ""), "tt", "t") elif tn == 32 and wordmap["kotus_av"] == "D": wordmap["stub"] = replace_rightmost(replace_rightmost(wordmap["stub"], "et", ""), "k", "") elif (tn in range(1, 16) or tn in range(17, 22)) and wordmap["kotus_av"] == "E": wordmap["stub"] = replace_rightmost(replace_rightmost(wordmap["stub"], "t", ""), "v", "p") elif (tn in range(1, 16) or tn in range(17, 22)) and wordmap["kotus_av"] == "F": wordmap["stub"] = replace_rightmost(replace_rightmost(wordmap["stub"], "t", ""), "d", "t") elif (tn in range(1, 16) or tn in range(17, 22)) and wordmap["kotus_av"] == "G": wordmap["stub"] = replace_rightmost(replace_rightmost(wordmap["stub"], "t", ""), "g", "k") elif (tn in range(1, 16) or tn in range(17, 22)) and wordmap["kotus_av"] == "H": wordmap["stub"] = replace_rightmost(replace_rightmost(wordmap["stub"], "t", ""), "mm", "mp") elif (tn in range(1, 16) or tn in range(17, 22)) and wordmap["kotus_av"] == "I": wordmap["stub"] = replace_rightmost(replace_rightmost(wordmap["stub"], "t", ""), "ll", "lt") elif (tn in range(1, 16) or tn in range(17, 22)) and wordmap["kotus_av"] == "J": wordmap["stub"] = replace_rightmost(replace_rightmost(wordmap["stub"], "t", ""), "nn", "nt") elif (tn in range(1, 16) or tn in range(17, 22)) and wordmap["kotus_av"] == "K": wordmap["stub"] = replace_rightmost(replace_rightmost(wordmap["stub"], "t", ""), "rr", "rt") elif (tn in range(1, 16) or tn in range(17, 22)) and wordmap["kotus_av"] == "L": wordmap["stub"] = replace_rightmost(replace_rightmost(wordmap["stub"], "t", ""), "j", "k") elif (tn in range(1, 16) or tn in range(17, 22)) and wordmap["kotus_av"] == "M": wordmap["stub"] = replace_rightmost(replace_rightmost(wordmap["stub"], "t", ""), "v", "k") elif (tn in [23, 24, 25, 26, 29, 30]) and wordmap["kotus_av"] == "G": wordmap["stub"] = replace_rightmost(replace_rightmost(wordmap["stub"], "t", ""), "g", "k") elif tn == 16 and wordmap["kotus_av"] == "H": wordmap["stub"] = wordmap["stub"][:-3] + "pi" elif tn == 28 and wordmap["kotus_av"] == "J": wordmap["stub"] = replace_rightmost(wordmap["stub"], "nnet", "nsi") elif tn == 33 and wordmap["kotus_av"] in ["A", "B", "C", "D"]: wordmap["stub"] = wordmap["stub"][:-5] + "in" elif tn == 33 and wordmap["kotus_av"] == "E": wordmap["stub"] = wordmap["stub"][:-5] + "vin" elif tn == 33 and wordmap["kotus_av"] == "F": wordmap["stub"] = wordmap["stub"][:-5] + "din" elif tn == 33 and wordmap["kotus_av"] == "G": wordmap["stub"] = wordmap["stub"][:-5] + "gin" elif tn == 33 and wordmap["kotus_av"] == "H": wordmap["stub"] = wordmap["stub"][:-5] + "min" elif tn == 33 and wordmap["kotus_av"] == "I": wordmap["stub"] = wordmap["stub"][:-5] + "lin" elif tn == 33 and wordmap["kotus_av"] == "J": wordmap["stub"] = wordmap["stub"][:-5] + "nin" elif tn == 33 and wordmap["kotus_av"] == "K": wordmap["stub"] = wordmap["stub"][:-5] + "rin" elif tn == 41 and wordmap["kotus_av"] in ["A", "B", "C", "D"]: wordmap["stub"] = wordmap["stub"][:-4] + "as" elif tn == 41 and wordmap["kotus_av"] == "E": wordmap["stub"] = wordmap["stub"][:-4] + "vas" elif tn == 41 and wordmap["kotus_av"] == "F": wordmap["stub"] = wordmap["stub"][:-4] + "das" elif tn == 41 and wordmap["kotus_av"] == "G": wordmap["stub"] = wordmap["stub"][:-4] + "gas" elif tn == 41 and wordmap["kotus_av"] == "H": wordmap["stub"] = wordmap["stub"][:-4] + "mas" elif tn == 41 and wordmap["kotus_av"] == "I": wordmap["stub"] = wordmap["stub"][:-4] + "las" elif tn == 41 and wordmap["kotus_av"] == "J": wordmap["stub"] = wordmap["stub"][:-4] + "nas" elif tn == 41 and wordmap["kotus_av"] == "K": wordmap["stub"] = wordmap["stub"][:-4] + "ras" elif tn == 48 and wordmap["kotus_av"] in ["A", "B", "C", "D"]: wordmap["stub"] = wordmap["stub"][:-4] + "e" elif tn == 48 and wordmap["kotus_av"] == "E": wordmap["stub"] = wordmap["stub"][:-4] + "ve" elif tn == 48 and wordmap["kotus_av"] == "F": wordmap["stub"] = wordmap["stub"][:-4] + "de" elif tn == 48 and wordmap["kotus_av"] == "G": wordmap["stub"] = wordmap["stub"][:-4] + "ge" elif tn == 48 and wordmap["kotus_av"] == "H": wordmap["stub"] = wordmap["stub"][:-4] + "me" elif tn == 48 and wordmap["kotus_av"] == "I": wordmap["stub"] = wordmap["stub"][:-4] + "le" elif tn == 48 and wordmap["kotus_av"] == "J": wordmap["stub"] = wordmap["stub"][:-4] + "ne" elif tn == 48 and wordmap["kotus_av"] == "K": wordmap["stub"] = wordmap["stub"][:-4] + "re" elif tn == 48 and wordmap["kotus_av"] == "L": wordmap["stub"] = wordmap["stub"][:-4] + "je" else: print("Unhandled plt in ", wordmap, file=stderr) return None else: if tn in range(1, 7) or tn in range(8, 16) or tn in range(17, 22): wordmap["stub"] = replace_rightmost(wordmap["stub"], "t", "") elif tn in [7, 23, 24, 25, 26, 29, 30]: wordmap["stub"] = replace_rightmost(wordmap["stub"], "et", "i") elif tn == 16: wordmap["stub"] = wordmap["stub"][:-3] + "pi" elif tn == 16: wordmap["stub"] = wordmap["stub"][:-2] elif tn in [27, 28]: wordmap["stub"] = wordmap["stub"][:-3] + "si" wordmap["kotus_av"] = False elif tn == 31: wordmap["stub"] = wordmap["stub"][:-4] + "ksi" elif tn == 32: wordmap["stub"] = wordmap["stub"][:-2] elif tn == 33: wordmap["stub"] = wordmap["stub"][:-3] + "n" elif tn == 34: wordmap["stub"] = wordmap["stub"][:-5] + "{oö}n" elif tn == 35: wordmap["stub"] = wordmap["stub"][:-5] + "min" elif tn == 36 or tn == 37: wordmap["stub"] = wordmap["stub"][:-4] + "n" elif tn == 38: wordmap["stub"] = wordmap["stub"][:-3] + "nen" elif tn == 39: wordmap["stub"] = wordmap["stub"][:-4] + "s" elif tn == 40: wordmap["stub"] = wordmap["stub"][:-3] + "s" elif tn == 41: wordmap["stub"] = wordmap["stub"][:-2] + "s" elif tn == 42: wordmap["stub"] = wordmap["stub"][:-3] + "s" elif tn == 43: wordmap["stub"] = wordmap["stub"][:-2] + "t" elif tn == 47: wordmap["stub"] = wordmap["stub"][:-3] + "{uy}t" elif tn == 48: wordmap["stub"] = wordmap["stub"][:-3] + "e" elif tn == 49: wordmap["stub"] = wordmap["stub"][:-3] else: print("Unhandled plurale tantum in", wordmap, file=stderr) return None if wordmap["harmony"] == "front": wordmap["stub"] = wordmap["stub"].replace("{uy}", "y") wordmap["stub"] = wordmap["stub"].replace("{oö}", "ö") elif wordmap["harmony"] == "back": wordmap["stub"] = wordmap["stub"].replace("{uy}", "u") wordmap["stub"] = wordmap["stub"].replace("{oö}", "o") wordmap["gradestem"] = wordmap["stub"] return wordmap