MCPcopy Index your code
hub / github.com/huichen/sego / tokenToString

Function tokenToString

utils.go:31–48  ·  view source on GitHub ↗
(token *Token)

Source from the content-addressed store, hash-verified

29}
30
31func tokenToString(token *Token) (output string) {
32 hasOnlyTerminalToken := true
33 for _, s := range token.segments {
34 if len(s.token.segments) > 1 {
35 hasOnlyTerminalToken = false
36 }
37 }
38
39 if !hasOnlyTerminalToken {
40 for _, s := range token.segments {
41 if s != nil {
42 output += tokenToString(s.token)
43 }
44 }
45 }
46 output += fmt.Sprintf("%s/%s ", textSliceToString(token.text), token.pos)
47 return
48}
49
50// 输出分词结果到一个字符串slice
51//

Callers 1

SegmentsToStringFunction · 0.85

Calls 1

textSliceToStringFunction · 0.85

Tested by

no test coverage detected