-
Notifications
You must be signed in to change notification settings - Fork 822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
第三章HMM中的viterbi的max函数 #25
Comments
是不是用了自己做的语料?若果是,可能是语料不好。 |
最好用来分析短句子,长文本的话V矩阵,超过一定的迭代后,计算结果会很小,最后趋于为0,导致for y0 in states if V[t - 1][y0] > 0的结果是空。可以采用对数概率相加来解决下溢的问题。 |
128行 for y0 in states if V[t - 1][y0] > 0]),会出现上一时刻不存在的状态如“B”,应该修改为 |
…better performance results This closes nlpinaction#24, closes nlpinaction#25 and closes nlpinaction#34
当需要分词的是一个文本段落时,viterbi函数中的max函数报错
Traceback (most recent call last):
File "D:\code\python_test\test\start.py", line 11, in
print(str(list(res)))
File "D:\code\python_test\test\hmm.py", line 150, in cut
prob, pos_list = self.viterbi(text, self.state_list, self.Pi_dic, self.A_dic, self.B_dic)
File "D:\code\python_test\test\hmm.py", line 134, in viterbi
for y0 in states if V[t - 1][y0] > 0])
ValueError: max() arg is an empty sequence
The text was updated successfully, but these errors were encountered: