-
Notifications
You must be signed in to change notification settings - Fork 1
/
settingsjson_test.go
69 lines (64 loc) · 1.74 KB
/
settingsjson_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package gosudachi
import (
"strings"
"testing"
)
var s string = `
{
"path" : "/usr/local/share/sudachi",
"systemDict" : "system.dic",
"characterDefinitionFile" : "char.def",
"inputTextPlugin" : [
{ "class" : "com.worksap.nlp.sudachi.DefaultInputTextPlugin" },
{ "class" : "com.worksap.nlp.sudachi.ProlongedSoundMarkInputTextPlugin",
"prolongedSoundMarks" : ["ー", "-", "⁓", "〜", "〰"],
"replacementSymbol" : "ー"
}
],
"oovProviderPlugin" : [
{
"class" : "com.worksap.nlp.sudachi.MeCabOovProviderPlugin",
"charDef" : "char.def",
"unkDef" : "unk.def"
},
{
"class" : "com.worksap.nlp.sudachi.SimpleOovProviderPlugin",
"oovPOSStrings" : [ "補助記号", "一般", "*", "*", "*", "*" ],
"leftId" : 5968,
"rightId" : 5968,
"cost" : 3857
}
],
"pathRewritePlugin" : [
{
"name" : "JoinNumericPlugin",
"enableNormalize" : false
},
{
"name" : "JoinKatakanaOovPlugin",
"oovPOS" : [ "名詞", "普通名詞", "一般", "*", "*", "*" ],
"minLength" : 3
}
]
}
`
// TestSettingsJSON_ParseSettingsJSON
func TestSettingsJSON_ParseSettingsJSON(t *testing.T) {
settings := NewSettingsJSON()
err := settings.ParseSettingsJSON("", strings.NewReader(s))
if err != nil {
t.Errorf("fail to parse json: %s", err)
}
bc := settings.GetBaseConfig()
want := "/usr/local/share/sudachi/system.dic"
if bc.SystemDict != want {
t.Errorf("invalid result. want = %s, got = %s", want, bc.SystemDict)
}
iplugins, err := settings.GetInputTextPluginArray(DefMakeInputTextPlugin)
if err != nil {
t.Errorf("GetInputTextPluginArray: %s", err)
}
if len(iplugins) != 2 {
t.Errorf("invalid result. want = 2, got = %d", len(iplugins))
}
}