Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_custom_pinyin_dict2():
hans = ['同行']
try:
assert lazy_pinyin(hans, style=TONE2) == ['to2ng', 'ha2ng']
except AssertionError:
pass
load_phrases_dict({'同行': [['tóng'], ['xíng']]})
assert lazy_pinyin(hans, style=TONE2) == ['to2ng', 'xi2ng']
def test_retrain():
seg = mmseg.seg
assert list(seg.cut('啊啊啊')) == ['啊', '啊', '啊']
load_phrases_dict({'啊啊啊': [['a'], ['a'], ['a']]})
mmseg.retrain(seg)
assert list(seg.cut('啊啊啊')) == ['啊啊啊']
def test_custom_pinyin_dict2_tone2():
load_phrases_dict({'同行': [['to4ng'], ['ku1']]}, style='tone2')
assert lazy_pinyin(['同行'], style=TONE2) == ['to4ng', 'ku1']
assert pinyin('同行') == [['tòng'], ['kū']]
alpha_pronuce = {"A": "ei ", "B": "bii ", "C": "sii ", "D": "dii ", "E": "ii ", "F": "ef ", "G": "dji ", "H": "eich ",
"I": "ai ", "J": "jei ", "K": "kei ", "L": "el ", "M": "em ", "N": "en ",
"O": "eo ", "P": "pii ", "Q": "kiu ", "R": "aa ", "S": "es ", "T": "tii ", "U": "iu ", "V": "vii ",
"W": "dabliu ", "X ": "eiks ", "Y": "wai ", "Z": "zii "}
# PUNCTUATION2 = r'“”()×"\'()*#' # 其它符号
# load_phrases_dict({u'360': [[u'jú'], [u'zǐ']]})
def json_load():
with open("user_dict/fault-tolerant_word.json", "r") as rf:
data = json.load(rf)
return data
usr_phrase = json_load()
load_phrases_dict(usr_phrase)
def text2pinyin(syllables):
temp = []
for syllable in syllables:
for p in PUNCTUATION:
syllable = syllable.replace(p, "")
# print(syllable)
# if syllable.isdigit():
try:
syllable = atc.num2chinese(syllable)
# print("sy:", syllable)
new_sounds = lazy_pinyin(syllable, style=pypinyin.TONE2)
print("pinyin:" + str(new_sounds))
for e in new_sounds:
temp.append(e)
def _pre_pinyin_setting():
''' fix pinyin error'''
load_phrases_dict({'嗯':[['ēn']]})
def _pre_pinyin_setting():
''' fix pinyin error'''
load_phrases_dict({'嗯': [['ēn']]})
load_phrases_dict({'风云变幻': [['fēng'], ['yún'], ['bià'], ['huàn']]})
load_phrases_dict({'不破不立': [['bù'], ['pò'], ['bù'], ['lì']]})
def _pre_pinyin_setting():
''' fix pinyin error'''
load_phrases_dict({'嗯': [['ēn']]})
load_phrases_dict({'风云变幻': [['fēng'], ['yún'], ['bià'], ['huàn']]})
load_phrases_dict({'不破不立': [['bù'], ['pò'], ['bù'], ['lì']]})