def trans_words(word): words_dict = {} for pair in eng_repls: eng_word, ru_word = pair.split(':') words_dict[eng_word] = ru_word.strip() new_word = replacer(word, words_dict) return new_word
def trans_literals(word): literal_dict = { 'b': 'б', 'd': 'д', 'f': 'ф', 'g': 'г', 'h': 'х', 'j': 'дж', 'k': 'к', 'l': 'л', 'm': 'м', 'n': 'н', 'p': 'п', 'r': 'р', 's': 'с', 't': 'т', 'w': 'в', 'z': 'з', 'a': 'а', 'e': 'е', 'i': 'и', 'o': 'о', 'u': 'у' } new_word = replacer(word, literal_dict) return new_word
def trans_short_ngrams(word): short_ngrams_dict = OrderedDict({'qu':'кв', 'ie':'и', 'ue':'ью', 'eu':'ью', 'ck':'к', 'wh':'в', 'ch':'ч', 'th':'з', 'sh':'ш', 'ph':'ф', 'ee':'и', 'oar':'ор', 'oo':'у', 'ya':'я', 'ye':'е', 'yu':'ю', 'yi':'и', '\Ayo':'йо', 'ea':'и'}) new_word = replacer(word, short_ngrams_dict) return new_word
def trans_conditional(word): condit_ngrams_dict = OrderedDict({ '\Ales\Z': 'ле', '\Ac': 'к', '\A[eéè](?![euioayéèàù-])': 'э', '\Aeu': 'ев', 'u[eéè]u': 'е', 'ieu\Z': 'ью', 'u[eéè]\Z': 'ью', 'gi[eéè]\Z': 'ж', 'nc[eéè]\Z': 'нс', 'g\Z': 'ж', 'z\Z': 'ц', 'y\Z': 'и', 'tion(?=\w?\Z)': 'шн', 'g(?=[ieyéè])': 'ж', 'ai(?=[^euioayéèàù-]{2})': 'е', 'l[eéè]': 'ле', 'l[uù]': 'лю', '(?<=[euioayéèàù])x{?=[euioayéèàù]\w+}': 'кз', '(?<=[euioayéèàù])s(?=[euioayéèàù])': 'з', '(?<=\w{3})[e]\Z': '', '(?<=[rdgkzb])h(?!\Z)': '' }) new_word = replacer(word, condit_ngrams_dict) return new_word
def trans_literals(word): literal_dict = { 'b': 'б', 'c': 'к', 'd': 'д', 'f': 'ф', 'g': 'г', 'h': 'х', 'j': 'й', 'k': 'к', 'l': 'л', 'm': 'м', 'n': 'н', 'p': 'п', 'q': 'к', 'r': 'р', 's': 'с', 't': 'т', 'v': 'ф', 'w': 'в', 'x': 'кс', 'z': 'з', 'a': 'а', 'e': 'е', 'i': 'и', 'o': 'о', 'u': 'у', 'y': 'и', 'ß': 'сс', 'ö': 'ё', 'ä': 'э', 'ü': 'ю' } new_word = replacer(word, literal_dict) return new_word
def trans_literals(word): ngrams_dict = {'b':'б', 'c':'к', 'd':'д', 'f':'ф', 'g':'г', 'h':'х', 'j':'й', 'k':'к', 'l':'л', 'm':'м', 'n':'н', 'p':'п', 'q':'к', 'r':'р', 's':'с', 't':'т', 'v':'в', 'w':'в', 'x':'кс', 'z':'з', 'a+':'а', 'e+':'е', 'i+':'и', 'u+':'у', 'o+':'о', 'y+':'и'} new_word = replacer(word, ngrams_dict) return new_word
def trans_ends(word): ends_ngrams_dict = {'\Ay(?=[euioa])':'й', '\Ae(?![euioay-])':'э', '(?<=[euioa])y\Z':'й', '(?<![euioa])y\Z':'и', '(?<=[euioa])c(?=[euioay-])':'с'} new_word = replacer(word, ends_ngrams_dict) return new_word
def trans_long_ngrams(word): long_ngrams_dict = OrderedDict({ 'tsch': 'ч', 'sch': 'ш', 'chs': 'хс', 'ss': 'сс' }) new_word = replacer(word, long_ngrams_dict) return new_word
def trans_separate(word): single_letters_dict = {'\Ab\Z':'би', '\Ac\Z':'си', '\Ad\Z':'ди', '\Af\Z':'эф', '\Ag\Z':'джи', '\Ah\Z':'эйч', '\Aj\Z':'джей', '\Ak\Z':'кей', '\Al\Z':'эль', '\Am\Z':'эм', '\An\Z':'эн', '\Ap\Z':'пи', '\Aq\Z':'кью', '\Ar\Z':'эр', '\As\Z':'эс', '\At\Z':'ти', '\Av\Z':'ви', '\Aw\Z':'дабл ю', '\Ax\Z':'икс', '\Az\Z':'зед', '\Aa\Z':'эй', '\Ao\Z':'оу', '\Ai\Z':'ай', '\Au\Z':'ю', '\Ae\Z':'и', '\Ay\Z':'вай'} new_word = replacer(word, single_letters_dict) return new_word
def condit_ngrams(word): condit_ngrams_dict = {'(?<=[euioay])s(?=[euioay])':'з', 'l(?![euioaylk])':'ль', '\Ay(?=[euioa])':'й', '\Ae(?![euioay-])':'э', '(?<=[euioa])y\Z':'й', '(?<![euioa])y\Z':'и', '(?<=\w{3})e\Z': ''} new_word = replacer(word, condit_ngrams_dict) return new_word
def trans_literals(word): ngrams_dict = {'b':'б', 'c':'к', 'd':'д', 'f':'ф', 'g':'г', 'h':'х', 'j':'й', 'k':'к', 'l':'л', 'm':'м', 'n':'н', 'p':'п', 'q':'к', 'r':'р', 's':'с', 't':'т', 'v':'в', 'w':'в', 'x':'х', 'z':'з', 'a':'а', 'e':'е', 'i':'и', 'u':'у', 'o':'о', 'y':'и', 'ß':'сс', 'ö':'о', 'ä':'а', 'ü':'у', 'é':'е', 'è':'е', 'à':'а', 'ù':'у', 'ê':'е', 'â':'а', 'ô':'о', 'î':'и', 'û':'у', 'ë':'е', 'ï':'и', 'ÿ':'и', 'ç':'с'} new_word = replacer(word, ngrams_dict) return new_word
def trans_conditional(word): condit_ngrams_dict = OrderedDict({ '\Az':'з', #old '(?<!l)l(?![leuioay-])':'ль', 'l\Z':'ль', '(?<![euioay-])z':'ц', 'cc(?=[ei])':'чч', '(?<!s)c(?=[ei])':'ч', 'gg?(?=[ei])':'дж', '(?<![euioay-])eu(?![euioay-])':'ью', '\Ae(?![euioay-])':'э', '(?<=[euioa])i(?=\w[euioa])':'й', 'ue\Z':'ью'}) new_word = replacer(word, condit_ngrams_dict) return new_word
def trans_conditional(word): condit_ngrams_dict = OrderedDict({ 's(?=[euioay])': 'з', #'\Ah(?=[euioay])':'г', '(?<![eiiouay])z(?![euioay])': 'ц', '(?<=[euoiay])v(?=[euioay])': 'в', '(?<![euioay])ä': 'е', '\Ae(?![euioay-])': 'э', '(?<!\Ai)st': 'шт', 't?z\Z': 'ц', '\Ach': 'к' }) new_word = replacer(word, condit_ngrams_dict) return new_word
def trans_short_ngrams(word): short_ngrams_dict = OrderedDict({ 'ph': 'ф', 'qu': 'кв', 'sc': 'ск', 'cs': 'кс', 'th': 'т', 'oi': 'уа', 'ou': 'у', 'ay': 'ей', 'ie': 'ье' }) new_word = replacer(word, short_ngrams_dict) return new_word
def trans_short_ngrams(word): short_ngrams_dict = { 'sh': 'ш', 'ts': 'ц', 'ya': 'я', 'yo': 'е', 'yu': 'ю', 'aa': 'а', 'ee': 'е', 'uu': 'у', 'ii': 'и', 'oo': 'о' } new_word = replacer(word, short_ngrams_dict) return new_word
def trans_long_ngrams(word): long_ngrams_dict = OrderedDict({ 'eaux\Z': 'о', 'beaut': 'бьют', 'eau': 'о', 'ogne\Z': 'он', 'gnie': 'йн', 'agne': 'ейн', 'ouge': 'уж', 'oix': 'уа', 'iei': 'ье', 'oux': 'о', '(?<=\w)qu[eéè]\Z': 'к', 'ch': 'ш' }) new_word = replacer(word, long_ngrams_dict) return new_word
def trans_short_ngrams(word): short_ngrams_dict = OrderedDict({ 'ch': 'х', 'tz': 'ц', 'sp': 'шп', 'ck': 'к', 'ph': 'ф', 'sh': 'ш', 'eh': 'е', 'je': 'е', 'ju': 'ю', 'ja': 'я', 'qu': 'кв', 'ei': 'ей', 'ie': 'и', 'eu': 'ой' }) new_word = replacer(word, short_ngrams_dict) return new_word
def trans_conditional(word): condit_ngrams_dict = OrderedDict({ '(?<=[euioay])s(?=[euioay])':'з', 'ts(?=\w+)':'ц', # consonants + vowels 'c(?=[eiy])':'с', '(?<!g)g(?=[eiy])':'дж', 'a(?=[uw])':'о', # combinaions of particular letters '(?<=w)a(?=r)':'о', '\Awr(?=[euioay])':'р', 'j(?![euioay])':'ж', '(?<![euioay])th':'т', '(?<!e)ew':'ью', 'ow(?=\w{2})': 'оу', 'l(?=t)':'ль', # letters + futher combinations 'ea(?=(d|th|lth|sure|sant))':'е', 't(?=(ure|ural|ury))':'ч', # open syllable '(?<=[^euioay])y(?=\w[euioay])':'ай', '(?<=[^euioay])a(?=\w[euioay])':'ей', '(?<=[^euioay])i(?=\we\Z)': 'ай', # beginning of the word '\Ae(?![euioay-])':'э', '\Au(?![euioay-])':'ю', '\Ath':'с', '\Aeu':'ев', '\Ax(?![euioay])':'икс', # end of the word 'ie\Z':'и', 'ies\Z':'ис', 'th\Z':'с', 'ue\Z':'ю', 'ey\Z': 'и', 'ai\Z': 'ай', # vowels 'au':'о', '[ae]i|ey':'ей', # empty letters '(?<=[rdgkzb])h(?!\Z)':'', '(?<=\w{3})e\Z':''}) new_word = replacer(word, condit_ngrams_dict) return new_word
def trans_long_ngrams(word): long_ngram_dict = {'sch':'ш', 'ya':'я', '\Aand\Z':'энд'} new_word = replacer(word, long_ngram_dict) return new_word
def trans_long_ngrams(word): long_ngrams_dict = OrderedDict({ 'cch':'чч', 'zz':'цц', 'lum':'люм'}) new_word = replacer(word, long_ngrams_dict) return new_word
def trans_short_ngrams(word): short_ngrams_dict = {'qu':'кв', 'ch':'ч', 'sh':'ш', 'ck':'к', 'th':'т', 'ph':'ф', 'sc':'ск', 'you':'ю', '\Ac':'к'} new_word = replacer(word, short_ngrams_dict) return new_word
def trans_long_ngrams(word): long_ngrams_dict = {'ay':'ей','[ao]ught':'от', 'ueu':'е', 'you':'ю', 'chr':'кр', 'scq':'ск'} new_word = replacer(word, long_ngrams_dict) return new_word
def trans_short_ngrams(word): short_ngrams_dict = OrderedDict({ 'cc':'цц', 'ch':'к', 'qu':'кв', 'sh':'ш', 'ts':'ц'}) new_word = replacer(word, short_ngrams_dict) return new_word