-
Notifications
You must be signed in to change notification settings - Fork 7
/
stop_tokens_test.go
38 lines (35 loc) · 1.14 KB
/
stop_tokens_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
package gotokenizer
import "testing"
func TestStopTokens_IsStopToken(t *testing.T) {
stopTokens := NewStopTokens()
stopTokens.Load(stopTokensDictPath)
testNotToken := "xxx"
if stopTokens.IsStopToken(testNotToken) {
t.Errorf(errorFormat,
!stopTokens.IsStopToken(testNotToken), stopTokens.IsStopToken(testNotToken))
}
testIsToken := "."
checkIsStopTokens(stopTokens, testIsToken, t)
testIsToken = " "
checkIsStopTokens(stopTokens, testIsToken, t)
testIsToken = "。"
checkIsStopTokens(stopTokens, testIsToken, t)
testIsToken = "【"
checkIsStopTokens(stopTokens, testIsToken, t)
testIsToken = "】"
checkIsStopTokens(stopTokens, testIsToken, t)
testIsToken = "["
checkIsStopTokens(stopTokens, testIsToken, t)
testIsToken = "]"
checkIsStopTokens(stopTokens, testIsToken, t)
testIsToken = ","
checkIsStopTokens(stopTokens, testIsToken, t)
testIsToken = "的"
checkIsStopTokens(stopTokens, testIsToken, t)
}
func checkIsStopTokens(stopTokens *StopTokens, testIsToken string, t *testing.T) {
if !stopTokens.IsStopToken(testIsToken) {
t.Errorf(errorFormat,
!stopTokens.IsStopToken(testIsToken), stopTokens.IsStopToken(testIsToken))
}
}