sego icon indicating copy to clipboard operation
sego copied to clipboard

错误:当词典只有一个关键词并且该关键词在句首时,无法得到该分词

Open icoder528 opened this issue 7 years ago • 0 comments

字典文件内容:

张三 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

icoder528 avatar Oct 18 '18 07:10 icoder528