1
0
mirror of https://github.com/fumiama/jieba.git synced 2026-06-05 00:32:51 +08:00

优化 jieba

This commit is contained in:
源文雨
2022-11-30 16:00:56 +08:00
parent 4d76899e79
commit 6982ead703
8 changed files with 114 additions and 109 deletions

View File

@@ -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()