mirror of
https://github.com/fumiama/jieba.git
synced 2026-06-27 15:40:32 +08:00
small refactor
This commit is contained in:
@@ -128,15 +128,11 @@ func (p *Posseg) cutDAG(sentence string) chan WordTag {
|
|||||||
go func() {
|
go func() {
|
||||||
dag := p.DAG(sentence)
|
dag := p.DAG(sentence)
|
||||||
routes := p.Calc(sentence, dag)
|
routes := p.Calc(sentence, dag)
|
||||||
x := 0
|
|
||||||
var y int
|
var y int
|
||||||
runes := []rune(sentence)
|
runes := []rune(sentence)
|
||||||
length := len(runes)
|
length := len(runes)
|
||||||
buf := make([]rune, 0)
|
buf := make([]rune, 0)
|
||||||
for {
|
for x := 0; x < length; {
|
||||||
if x >= length {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
y = routes[x].Index + 1
|
y = routes[x].Index + 1
|
||||||
l_word := runes[x:y]
|
l_word := runes[x:y]
|
||||||
if y-x == 1 {
|
if y-x == 1 {
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ func viterbi(obs []rune) []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//use Go's map to implement Python's Set()
|
//use Go's map to implement Python's Set()
|
||||||
prev_states_expect_next := make(map[string]string)
|
prev_states_expect_next := make(map[string]int)
|
||||||
for _, x := range prev_states {
|
for _, x := range prev_states {
|
||||||
for y, _ := range probTrans[x] {
|
for y, _ := range probTrans[x] {
|
||||||
prev_states_expect_next[y] = y
|
prev_states_expect_next[y] = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmp_obs_states := charStateTab.get(obs[t])
|
tmp_obs_states := charStateTab.get(obs[t])
|
||||||
|
|||||||
Reference in New Issue
Block a user