mirror of
https://github.com/fumiama/jieba.git
synced 2026-06-08 18:40:24 +08:00
added example_test.go, rename analyse_test.go to tag_extracker_test.go, removed bench.sh
This commit is contained in:
22
analyse/example_test.go
Normal file
22
analyse/example_test.go
Normal file
@@ -0,0 +1,22 @@
|
||||
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++ / 伸手不见五指 / 孙悟空 / 黑夜 /
|
||||
}
|
||||
Reference in New Issue
Block a user