ahocorasick
ahocorasick copied to clipboard
exception case
异常case不能通过测试,无法命中“国人”这个词
func Test2(t *testing.T) {
ac := NewMatcher()
dictionary := []string{"中国人民", "国人", "hello世界", "hello"}
ac.Build(dictionary)
ret := ac.Match("中国人")
for _, v := range ret {
fmt.Println(v.Index, v.EndPosition)
}
//if len(ret) != 4 {
// t.Fatal()
//}
//
//ret = ac.Match("世界")
//if len(ret) != 1 {
// t.Fatal()
//}
//
//ret = ac.Match("hello")
//if len(ret) != 2 {
// t.Fatal()
//}
}