ValueError Traceback (most recent call last) <ipython-input-2-0d3cd6ee82f6> in <module> 144 text = 'D:/pythonProject/Ngram/test.txt' 145 res = hmm.cut(text) --> 146 print(str(list(res))) <ipython-input-2-0d3cd6ee82f6> in cut(self, text) 123 if not self.load_para: 124 self.try_laod_model(os.path.exists(self.model_file)) --> 125 prob, pos_list = self.viterbi(text, self.state_list, self.Pi_dic, self.A_dic, self.B_dic) 126 begin, next = 0, 0 127 for i, char in enumerate(text): <ipython-input-2-0d3cd6ee82f6> in viterbi(self, text, states, start_p, trans_p, emit_p) 108 emitP = emit_p[y].get(text[t], 0) if not neverSeen else 1.0 109 (prob, state) = max([(V[t - 1][y0] * trans_p[y0].get(y, 0) * emitP, y0) --> 110 for y0 in states if V[t - 1][y0] > 0]) 111 V[t][y] = prob 112 newpath[y] = path[state] + [y] ValueError: max() arg is an empty sequence
你传给max函数的数组或者列表是空的