1
0
mirror of https://github.com/fumiama/jieba.git synced 2026-07-01 17:40:29 +08:00

unify Cut method, return channel instead of array

This commit is contained in:
Wang Bin
2015-02-27 17:30:45 +08:00
parent c03b3eac1c
commit 43480db509
2 changed files with 125 additions and 115 deletions

View File

@@ -621,15 +621,23 @@ func init() {
SetDictionary("dict.txt")
}
func chanToArray(ch chan string) []string {
result := make([]string, 0)
for word := range ch {
result = append(result, word)
}
return result
}
func TestCutDAG(t *testing.T) {
result := cutDAG("BP神经网络如何训练才能在分类时增加区分度")
result := chanToArray(cutDAG("BP神经网络如何训练才能在分类时增加区分度"))
if len(result) != 11 {
t.Error(result)
}
}
func TestCutDAGNoHmm(t *testing.T) {
result := cutDAGNoHMM("BP神经网络如何训练才能在分类时增加区分度")
result := chanToArray(cutDAGNoHMM("BP神经网络如何训练才能在分类时增加区分度"))
if len(result) != 11 {
t.Error(result)
}
@@ -648,14 +656,6 @@ func TestRegexpSplit(t *testing.T) {
}
}
func chanToArray(ch chan string) []string {
result := make([]string, 0)
for word := range ch {
result = append(result, word)
}
return result
}
func TestDefaultCut(t *testing.T) {
var result []string
for index, content := range test_contents {