-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
43 lines (36 loc) · 862 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Package main provides ...
package main
import (
"fmt"
"github.com/getbuguai/fts"
)
type Docs struct {
fts.SimpleDocument
}
func main() {
fmt.Println("Hello BuGuai !!! ")
var strs = []string{"你好", "射门申请", "看看看么", "看看", "说是拉开"}
fts.DefaultSplitString = fts.ChaineseSplitString
fts.DocumentAdd(sliceStrToSimpleDocument(strs))
// TODO: 中文叠词错误,会匹配 [看看看么,看看]
ds, err := fts.DocumentSearch("看看看看")
if err != nil {
fmt.Println("DocumentSearch", err)
return
}
for _, d := range ds {
s := d.(*Docs)
fmt.Println(s.GetText())
}
}
func sliceStrToSimpleDocument(slicesStrs []string) []fts.Document {
res := make([]fts.Document, len(slicesStrs))
for i, v := range slicesStrs {
res[i] = &Docs{
SimpleDocument: fts.SimpleDocument{
Text: v,
},
}
}
return res
}