Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
icoder528 opened this issue Oct 18, 2018 · 0 comments

Comments

@icoder528
Copy link

字典文件内容:

张三 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant