from pypinyin.standard import convert_finals
from pypinyin.style._utils import get_initials, get_finals
from pypinyin import Style, pinyin
from build_corpus import align2, split_initials_finals, wenzi2pinyin
from pypinyin.core import lazy_pinyin

with open("./data/voc/yunmu.txt","r",encoding="utf-8") as f:
    yunmus=f.readlines()
yunmus=[a.strip() for a in yunmus]

a = 'zhi'
a=convert_finals(a)
print(a)
strict = True
if get_initials(a, strict)=="":
    print("True")

text="儿童节的设立"
# ，Datsun新推出的轻型跑车可谓一呜惊人。

# pinyins,tones=wenzi2pinyin(text)
# print(lazy_pinyin(text, style=Style.TONE3))

# print(lazy_pinyin(text, style=Style.TONE3))

# pnyns = [split_initials_finals(a) for a in lazy_pinyin(text, style=Style.TONE3)]
# print(pnyns)
text = text.replace(" ","")
# print(wenzi2pinyin(text))
pnyns, hanzis=align2(text)

print(pnyns)
print(hanzis)

print('%s %s' % (get_initials(a, strict), get_finals(a, strict)))