-
Notifications
You must be signed in to change notification settings - Fork 0
/
dawg_test.go
44 lines (35 loc) · 985 Bytes
/
dawg_test.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
44
package dawg_test
import (
"fmt"
"testing"
"github.com/ciscorn/dawg-go"
)
func Test_Foobar(t *testing.T) {
builder := dawg.NewBuilder()
builder.AddWord("top")
builder.AddWord("tops")
builder.AddWord("tap")
builder.AddWord("taps")
d := builder.Build()
// dawg.DumpAsDot(os.Stdout)
// dawg.DumpAsMermaid(os.Stdout)
// FIXME
fmt.Println(d.Contains("top"))
fmt.Println(d.Contains("tops"))
fmt.Println(d.Contains("tap"))
fmt.Println(d.Contains("taps"))
fmt.Println(d.Contains("zaps"))
fmt.Println(d.Contains("ta"))
fmt.Println(d.Contains("to"))
fmt.Println(d.Contains("tapsy"))
fmt.Println(d.ContainsPrefix("t"))
fmt.Println(d.ContainsPrefix("to"))
fmt.Println(d.ContainsPrefix("top"))
fmt.Println(d.ContainsPrefix("tops"))
fmt.Println(d.ContainsPrefix("topsi"))
fmt.Println(d.ContainsPrefix("tapsy"))
for r := range dawg.FuzzySearch(d, "topz") {
fmt.Printf("%+v\n", r)
}
fmt.Println(dawg.ExtractKeywords(d, "this is tops top hits tap taps feee"))
}