1
0
mirror of https://github.com/fumiama/jieba.git synced 2026-06-18 17:30:24 +08:00

change cut method to return a channel string, not []string

This commit is contained in:
Wang Bin
2015-02-27 11:37:55 +08:00
parent 87fe3a19f8
commit 76b9df8511
4 changed files with 91 additions and 80 deletions

View File

@@ -10,14 +10,13 @@ func Tokenize(sentence string, mode string, HMM bool) []Token {
tokens := make([]Token, 0)
start := 0
var width int
if mode == "default" {
for _, word := range Cut(sentence, false, HMM) {
for word := range Cut(sentence, false, HMM) {
if mode == "default" {
width = len([]rune(word))
tokens = append(tokens, Token{word, start, start + width})
start += width
}
} else {
for _, word := range Cut(sentence, false, HMM) {
} else {
runes := []rune(word)
width = len(runes)
for _, step := range []int{2, 3} {