mirror of
https://github.com/fxsjy/jieba.git
synced 2025-07-10 00:01:33 +08:00
fix the bug of issue#137
This commit is contained in:
parent
cc708de40c
commit
9d4ac26f16
@ -1,5 +1,6 @@
|
||||
import operator
|
||||
MIN_FLOAT=-3.14e100
|
||||
MIN_INF=float("-inf")
|
||||
|
||||
def get_top_states(t_state_v,K=4):
|
||||
items = t_state_v.items()
|
||||
@ -27,7 +28,7 @@ def viterbi(obs, states, start_p, trans_p, emit_p):
|
||||
if len(obs_states)==0: obs_states = all_states
|
||||
|
||||
for y in obs_states:
|
||||
(prob,state ) = max([(V[t-1][y0] + trans_p[y0].get(y,MIN_FLOAT) + emit_p[y].get(obs[t],MIN_FLOAT) ,y0) for y0 in prev_states])
|
||||
(prob,state ) = max([(V[t-1][y0] + trans_p[y0].get(y,MIN_INF) + emit_p[y].get(obs[t],MIN_FLOAT) ,y0) for y0 in prev_states])
|
||||
V[t][y] =prob
|
||||
mem_path[t][y] = state
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user