yuanyin_list = [
{"āáǎăà": [{"ā": "1"}, {"ă": "3"}, {"á": "2"}, {"ǎ": "3"}, {"à": "4"}], "yuanyin": "a"},
{"ōŏóǒò": [{"ō": "1"}, {"ó": "2"}, {"ǒ": "3"}, {"ŏ": "3"}, {"ò": "4"}, ], "yuanyin": "o"},
{"ēéĕè": [{"ē": "1"}, {"é": "2"}, {"ĕ": "3"}, {"è": "4"}, ], "yuanyin": "e"},
{"īíǐĭì": [{"ī": "1"}, {"í": "2"}, {"ǐ": "3"}, {"ĭ": "3"}, {"ì": "4"}, ], "yuanyin": "i"},
{"ūúǔŭŭù": [{"ū": "1"}, {"ú": "2"}, {"ǔ": "3"}, {"ŭ": "3"}, {"ù": "4"}, ], "yuanyin": "u"},
{"ǖǘǚǜ": [{"ǖ": "1"}, {"ǘ": "2"}, {"ǚ": "3"}, {"ǜ": "4"}, ], "yuanyin": "ü"},
]
def parsed_yin(yin_list):
new_yin_list = []
for yin in yin_list:
for i in yin:
if i in "āáǎăàōŏóǒòēéĕèīíǐĭìūúǔŭŭùǖǘǚǜ":
for yuanyin in yuanyin_list:
for key in yuanyin.keys():
if i in key:
yuanyin_dic_list = yuanyin.get(key)
for dic in yuanyin_dic_list:
if i in dic:
yuanyin_ = yuanyin.get("yuanyin")
yin = yin.replace(i, yuanyin_)
num = dic.get(i)
yin = yin + str(num)
new_yin_list.append(yin)
return new_yin_list
if __name__ == "__main__":
import json
yin = ['zhĕn']
pinyin_str="yī qǔ yáng guān"
for yin in pinyin_str.split():
print(parsed_yin([yin]))