1
0
mirror of https://github.com/fumiama/jieba.git synced 2026-07-01 17:40:29 +08:00

initial commit

This commit is contained in:
Wang Bin
2013-10-31 18:20:04 +08:00
commit 8c785ad36a
24 changed files with 831685 additions and 0 deletions

46
posseg/viterbi_test.go Normal file
View File

@@ -0,0 +1,46 @@
package posseg
import (
"testing"
)
var (
route1 = []StateTag{
StateTag{'B', "nr"},
StateTag{'M', "nr"},
StateTag{'E', "nr"},
StateTag{'S', "v"},
StateTag{'B', "v"},
StateTag{'E', "v"},
StateTag{'B', "n"},
StateTag{'M', "n"},
StateTag{'E', "n"},
StateTag{'S', "d"},
StateTag{'S', "v"},
StateTag{'S', "n"},
StateTag{'B', "v"},
StateTag{'E', "v"},
StateTag{'B', "nr"},
StateTag{'M', "nr"},
StateTag{'M', "nr"},
StateTag{'M', "nr"},
StateTag{'E', "nr"},
StateTag{'S', "zg"}}
)
func TestViterbi(t *testing.T) {
ss := "李小福是创新办主任也是云计算方面的专家;"
prob, route := Viterbi([]rune(ss))
if prob != MIN_FLOAT {
t.Error(prob)
}
if len(route) != len(route1) {
t.Error(len(route))
}
for index, _ := range route {
if route[index] != route1[index] {
t.Error(route[index])
}
}
}