-
Notifications
You must be signed in to change notification settings - Fork 358
Open
Description
字典文件内容:
张三 3 n
程序:
var sgr sego.Segmenter
sgr.LoadDictionary("main.dic")
var words []string
for _, sg := range sgr.Segment([]byte("张三,你好啊")) {
token := sg.Token()
words = append(words, fmt.Sprintf("%s/%s", token.Text(), token.Pos()))
}
fmt.Println(strings.Join(words, " "))
// 张/x 三/x ,/x 你/x 好/x 啊/x
words = words[:0]
for _, sg := range sgr.Segment([]byte("你好啊,张三")) {
token := sg.Token()
words = append(words, fmt.Sprintf("%s/%s", token.Text(), token.Pos()))
}
fmt.Println(strings.Join(words, " "))
// 你/x 好/x 啊/x ,/x 张三/n
Metadata
Metadata
Assignees
Labels
No labels