1
0
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:
Wang Bin
2015-05-06 15:57:05 +08:00
parent 4e8887da5e
commit f96acf3e85
5 changed files with 24 additions and 5 deletions

22
analyse/example_test.go Normal file
View 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++ / 伸手不见五指 / 孙悟空 / 黑夜 /
}