Skip to content

Commit 205e001

Browse files
author
hero
committed
添加sego中文分词工具
1 parent bff804d commit 205e001

File tree

2 files changed

+589048
-2
lines changed

2 files changed

+589048
-2
lines changed

similarity_code/cosine_test.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
package similarity_code
22

33
import (
4-
"fmt"
4+
"github.com/huichen/sego"
55
"testing"
66
)
77

88
func TestCosine(t *testing.T) {
9-
fmt.Println(Cosine([]float64{1, 1, 1, 1, 1}, []float64{1, 0, 1, 1, 1, 1, 1, 1}))
9+
t.Log(Cosine([]float64{1, 1, 1, 1, 1}, []float64{1, 0, 1, 1, 1, 1, 1, 1}))
10+
}
11+
12+
func TestSego(t *testing.T) {
13+
var segmenter sego.Segmenter
14+
segmenter.LoadDictionary("./dictionary.txt")
15+
segments := segmenter.Segment([]byte("梦是美好的吗?我不能确定,但也不是悲伤的。天使的彩色羽翼张开,羽毛飘落,每一片羽毛都有一个梦,你的梦是什么颜色的羽毛?"))
16+
a := sego.SegmentsToSlice(segments, false)
17+
b := sego.SegmentsToString(segments, true)
18+
for _, v := range a {
19+
t.Log("a >>>>>>", v)
20+
}
21+
for _, v := range b {
22+
t.Log("b >>>>>>", v)
23+
}
1024
}

0 commit comments

Comments
 (0)