mirror of
https://github.com/fumiama/jieba.git
synced 2026-06-05 00:32:51 +08:00
优化 jieba
This commit is contained in:
@@ -16,7 +16,7 @@ type line struct {
|
||||
}
|
||||
|
||||
var (
|
||||
segmenter = Segmenter{}
|
||||
segmenter *Segmenter
|
||||
numThreads = runtime.NumCPU()
|
||||
task = make(chan line, numThreads)
|
||||
result = make(chan line, numThreads)
|
||||
@@ -35,9 +35,6 @@ func Example_parallelCut() {
|
||||
// Set the number of goroutines
|
||||
runtime.GOMAXPROCS(numThreads)
|
||||
|
||||
// Load dictionary
|
||||
segmenter.LoadDictionaryAt("dict.txt")
|
||||
|
||||
// open file for segmentation
|
||||
file, err := os.Open("README.md")
|
||||
if err != nil {
|
||||
@@ -45,6 +42,12 @@ func Example_parallelCut() {
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
// Load dictionary
|
||||
segmenter, err = LoadDictionaryAt("dict.txt")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// start worker routines
|
||||
for i := 0; i < numThreads; i++ {
|
||||
go worker()
|
||||
|
||||
Reference in New Issue
Block a user