ai-content-maker/.venv/Lib/site-packages/g2pkk/regular.py

106 lines
2.7 KiB
Python

# -*- coding: utf-8 -*-
'''
https://github.com/kyubyong/g2pK
'''
from g2pkk.utils import gloss, get_rule_id2text
rule_id2text = get_rule_id2text()
def link1(inp, descriptive=False, verbose=False):
rule = rule_id2text["13"]
out = inp
pairs = [ ("ᆨᄋ", ""),
("ᆩᄋ", ""),
("ᆫᄋ", ""),
("ᆮᄋ", ""),
("ᆯᄋ", ""),
("ᆷᄋ", ""),
("ᆸᄋ", ""),
("ᆺᄋ", ""),
("ᆻᄋ", ""),
("ᆽᄋ", ""),
("ᆾᄋ", ""),
("ᆿᄋ", ""),
("ᇀᄋ", ""),
("ᇁᄋ", "")]
for str1, str2 in pairs:
out = out.replace(str1, str2)
gloss(verbose, out, inp, rule)
return out
def link2(inp, descriptive=False, verbose=False):
rule = rule_id2text["14"]
out = inp
pairs = [ ("ᆪᄋ", "ᆨᄊ"),
("ᆬᄋ", "ᆫᄌ"),
("ᆰᄋ", "ᆯᄀ"),
("ᆱᄋ", "ᆯᄆ"),
("ᆲᄋ", "ᆯᄇ"),
("ᆳᄋ", "ᆯᄊ"),
("ᆴᄋ", "ᆯᄐ"),
("ᆵᄋ", "ᆯᄑ"),
("ᆹᄋ", "ᆸᄊ") ]
for str1, str2 in pairs:
out = out.replace(str1, str2)
gloss(verbose, out, inp, rule)
return out
def link3(inp, descriptive=False, verbose=False):
rule = rule_id2text["15"]
out = inp
pairs = [ ("ᆨ ᄋ", ""),
("ᆩ ᄋ", ""),
("ᆫ ᄋ", ""),
("ᆮ ᄋ", ""),
("ᆯ ᄋ", ""),
("ᆷ ᄋ", ""),
("ᆸ ᄋ", ""),
("ᆺ ᄋ", ""),
("ᆻ ᄋ", ""),
("ᆽ ᄋ", ""),
("ᆾ ᄋ", ""),
("ᆿ ᄋ", ""),
("ᇀ ᄋ", ""),
("ᇁ ᄋ", ""),
("ᆪ ᄋ", "ᆨ ᄊ"),
("ᆬ ᄋ", "ᆫ ᄌ"),
("ᆰ ᄋ", "ᆯ ᄀ"),
("ᆱ ᄋ", "ᆯ ᄆ"),
("ᆲ ᄋ", "ᆯ ᄇ"),
("ᆳ ᄋ", "ᆯ ᄊ"),
("ᆴ ᄋ", "ᆯ ᄐ"),
("ᆵ ᄋ", "ᆯ ᄑ"),
("ᆹ ᄋ", "ᆸ ᄊ") ]
for str1, str2 in pairs:
out = out.replace(str1, str2)
gloss(verbose, out, inp, rule)
return out
def link4(inp, descriptive=False, verbose=False):
rule = rule_id2text["12.4"]
out = inp
pairs = [ ("ᇂᄋ", ""),
("ᆭᄋ", ""),
("ᆶᄋ", "") ]
for str1, str2 in pairs:
out = out.replace(str1, str2)
gloss(verbose, out, inp, rule)
return out