Esempio n. 1
0
    def _prepare(self):
        self.pinyin_phrase = pinyin_phrase_loader()
        self.pinyin_char = pinyin_char_loader()

        # 加载 trie 树
        self.trie_tree_obj = TrieTree()
        self.trie_tree_obj.build_trie_tree(self.pinyin_phrase, 'phrase')
        self.trie_tree_obj.build_trie_tree(self.pinyin_char, 'char')
Esempio n. 2
0
    def _prepare(self):
        self.py_unk = '<py_unk>'
        self.py_unk_detail = {'consonant': '', 'vowel': '', 'tone': ''}

        consonants = 'bcdfghjklmnpqrstwxyz'
        consonants = list(consonants)
        self.consonants = ['zh', 'ch', 'sh', 'ng', 'hm', 'hng']
        self.consonants.extend(consonants)

        self.tones = '12345'

        self.pinyin_phrase = pinyin_phrase_loader()
        self.pinyin_char = pinyin_char_loader()
        #pdb.set_trace()
        # 加载 trie 树
        self.trie_tree_obj = TrieTree()
        self.trie_tree_obj.build_trie_tree(self.pinyin_phrase, 'phrase')
        self.trie_tree_obj.build_trie_tree(self.pinyin_char, 'char')

        # 格式转换
        self._pinyin_formater()