Trie树中插入单词
(self, word, usertag)
| 60 | self.insert(w, t) |
| 61 | |
| 62 | def insert(self, word, usertag): |
| 63 | """Trie树中插入单词""" |
| 64 | l = len(word) |
| 65 | now = self.trie |
| 66 | for i in range(l): |
| 67 | c = word[i] |
| 68 | if not c in now.children: |
| 69 | now.children[c] = TrieNode(False) |
| 70 | now = now.children[c] |
| 71 | now.isword = True |
| 72 | now.usertag = usertag |
| 73 | |
| 74 | def solve(self, txt): |
| 75 | """对文本进行预处理""" |
no test coverage detected