SegWords 分词
(sentence string, length ...int)
| 1106 | |
| 1107 | // SegWords 分词 |
| 1108 | func SegWords(sentence string, length ...int) (words []string) { |
| 1109 | topk := 5 |
| 1110 | if len(length) > 0 && length[0] > 0 { |
| 1111 | topk = length[0] |
| 1112 | } |
| 1113 | tags := te.ExtractTags(sentence, topk) |
| 1114 | for _, tag := range tags { |
| 1115 | words = append(words, tag.Text()) |
| 1116 | } |
| 1117 | return |
| 1118 | } |
| 1119 | |
| 1120 | // LongestCommonPrefix 查找最长共同前缀 |
| 1121 | func LongestCommonPrefix(strs []string) string { |