1
0
mirror of https://github.com/fumiama/jieba.git synced 2026-06-05 08:40:36 +08:00
Files
jieba/analyse/example_test.go

23 lines
551 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package analyse_test
import (
"fmt"
"github.com/wangbin/jiebago/analyse"
)
func ExampleExtractTags() {
var t analyse.TagExtracter
t.LoadDictionary("../dict.txt")
t.LoadIdf("idf.txt")
sentence := "这是一个伸手不见五指的黑夜。我叫孙悟空我爱北京我爱Python和C++。"
segments := t.ExtractTags(sentence, 5)
fmt.Printf("Top %d tags:", len(segments))
for _, segment := range segments {
fmt.Printf(" %s /", segment.Text())
}
// Output:
// Top 5 tags: Python / C++ / 伸手不见五指 / 孙悟空 / 黑夜 /
}