mirror of
https://github.com/fumiama/jieba.git
synced 2026-06-11 04:10:25 +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++ / 伸手不见五指 / 孙悟空 / 黑夜 /
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// Package analyse is the Golang implementation of Jieba's analyse module.
|
||||||
package analyse
|
package analyse
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
go test -run=XXX -v -bench=BenchmarkViterbi -benchtime 10s -benchmem -memprofile viterbi-mem.out -cpuprofile viterbi-cpu.out
|
|
||||||
go tool pprof -png -output ~/tmp/viterbi-cpu.png posseg.test viterbi-cpu.out
|
|
||||||
go tool pprof -png -output ~/tmp/viterbi-mem.png posseg.test viterbi-mem.out
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// Package posseg is the Golang implementation of Jieba's posseg module.
|
||||||
package posseg
|
package posseg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
Reference in New Issue
Block a user