def load_single_dict(pinyin_dict, style='default'): """载入用户自定义的单字拼音库 :param pinyin_dict: 单字拼音库。比如: ``{0x963F: u"ā,ē"}`` :param style: pinyin_dict 参数值的拼音库风格. 支持 'default', 'tone2' :type pinyin_dict: dict """ if style == 'tone2': for k, v in pinyin_dict.items(): v = _replace_tone2_style_dict_to_default(v) PINYIN_DICT[k] = v else: PINYIN_DICT.update(pinyin_dict) mmseg.retrain(mmseg.seg)
def load_phrases_dict(phrases_dict, style='default'): """载入用户自定义的词语拼音库 :param phrases_dict: 词语拼音库。比如: ``{u"阿爸": [[u"ā"], [u"bà"]]}`` :param style: phrases_dict 参数值的拼音库风格. 支持 'default', 'tone2' :type phrases_dict: dict """ if style == 'tone2': for k, value in phrases_dict.items(): v = [list(map(tone2_to_tone, pys)) for pys in value] PHRASES_DICT[k] = v else: PHRASES_DICT.update(phrases_dict) mmseg.retrain(mmseg.seg)