-
Notifications
You must be signed in to change notification settings - Fork 0
/
lemmy_test.go
54 lines (48 loc) · 1.01 KB
/
lemmy_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
45
46
47
48
49
50
51
52
53
54
package main
import (
"net/http"
"strings"
"testing"
)
var words = map[string]string{
"et": "et",
"oratio": "oratio",
"conviciis": "convicium",
"est": "sum",
}
func TestLemmatizeWord(t *testing.T) {
httpClient := &http.Client{}
for base, lemmyd := range words {
lemTest, _ := LemmatizeWord(httpClient, base)
t.Logf("%s:%s:%s", base, lemTest, lemmyd)
if lemTest != lemmyd {
t.Error("Lemmatize Failed for word " + base)
}
}
}
func TestLemmatizeText(t *testing.T) {
var in string
var out []string
mx := 10
cache_size := 10000
MAX_REQUESTS = &mx
CACHE_SIZE = &cache_size
for base, lemmyd := range words {
in += base + " "
out = append(out, lemmyd)
}
in = "//'\"`" + in
t.Log(in)
lr := NewLemmaReader(strings.NewReader(in))
i := 0
for w, done := lr.Read(); !done; w, done = lr.Read() {
t.Logf("%s:%s", w, out[i])
if w != out[i] {
t.Errorf("Lemmatize Failed for word index %d", i)
}
i++
}
if i != len(out) {
t.Error("Input and output counts do not match")
}
}