Skip to content

Commit ae4a385

Browse files
committed
增加一个单独测试用例
1 parent f105260 commit ae4a385

File tree

1 file changed

+58
-17
lines changed

1 file changed

+58
-17
lines changed

utils_test.go

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,53 +51,94 @@ func Test_Benchmark(t *testing.T) {
5151
fmt.Println(testing.Benchmark(TextSliceToString))
5252
}
5353

54-
55-
func Test_Token_TextEquals(t *testing.T){
54+
func Test_Token_TextEquals(t *testing.T) {
5655
token := Token{
57-
text:[]Text{
56+
text: []Text{
5857
[]byte("one"),
5958
[]byte("two"),
6059
},
6160
}
62-
assert.True(t,token.TextEquals("onetwo"))
61+
assert.True(t, token.TextEquals("onetwo"))
6362
}
6463

65-
func Test_Token_TextEquals_CN(t *testing.T){
64+
func Test_Token_TextEquals_CN(t *testing.T) {
6665
token := Token{
67-
text:[]Text{
66+
text: []Text{
6867
[]byte("中国"),
6968
[]byte("文字"),
7069
},
7170
}
72-
assert.True(t,token.TextEquals("中国文字"))
71+
assert.True(t, token.TextEquals("中国文字"))
7372
}
7473

75-
func Test_Token_TextNotEquals(t *testing.T){
74+
func Test_Token_TextNotEquals(t *testing.T) {
7675
token := Token{
77-
text:[]Text{
76+
text: []Text{
7877
[]byte("one"),
7978
[]byte("two"),
8079
},
8180
}
82-
assert.False(t,token.TextEquals("one-two"))
81+
assert.False(t, token.TextEquals("one-two"))
8382
}
8483

85-
func Test_Token_TextNotEquals_CN(t *testing.T){
84+
func Test_Token_TextNotEquals_CN(t *testing.T) {
8685
token := Token{
87-
text:[]Text{
86+
text: []Text{
8887
[]byte("中国"),
8988
[]byte("文字"),
9089
},
9190
}
92-
assert.False(t,token.TextEquals("中国文字1"))
91+
assert.False(t, token.TextEquals("中国文字1"))
9392
}
9493

95-
func Test_Token_TextNotEquals_CN_B(t *testing.T){
94+
func Test_Token_TextNotEquals_CN_B(t *testing.T) {
9695
token := Token{
97-
text:[]Text{
96+
text: []Text{
9897
[]byte("中国"),
9998
[]byte("文字"),
10099
},
101100
}
102-
assert.False(t,token.TextEquals("中国文"))
103-
}
101+
assert.False(t, token.TextEquals("中国文"))
102+
}
103+
104+
func Test_Token_Split(t *testing.T) {
105+
probMap := map[string]string{
106+
"衣门襟": "拉链",
107+
"品牌": "天奕",
108+
"图案": "纯色 字母",
109+
"颜色分类": "牛奶白 水粉色 湖水蓝 浅军绿 雅致灰",
110+
"尺码": "大码XL 大码XXL 大码XXXL 大码XXXXL",
111+
"组合形式": "单件",
112+
"面料": "聚酯",
113+
"领型": "连帽",
114+
"服饰工艺": "立体裁剪",
115+
"货号": "YZL-1806052",
116+
"厚薄": "超薄",
117+
"年份季节": "2018年夏季",
118+
"通勤": "韩版",
119+
"服装款式细节": "不对称",
120+
"成分含量": "81%(含)-90%(含)",
121+
"袖型": "常规",
122+
"风格": "通勤",
123+
"适用年龄": "18-24周岁",
124+
"服装版型": "宽松",
125+
"大码女装分类": "其它特大款式",
126+
"衣长": "中长款",
127+
"袖长": "长袖",
128+
"穿着方式": "开衫",
129+
}
130+
word := "卫衣女宽松拉链外套开衫韩版"
131+
var segmenter Segmenter
132+
segmenter.LoadDictionary("dictionary.txt")
133+
segments := segmenter.InternalSegment([]byte(word),true)
134+
for _,s := range segments{
135+
fmt.Println(s.token.Text())
136+
}
137+
for _, value := range probMap {
138+
for _, s := range segments {
139+
if s.Token().Text() == value {
140+
fmt.Println("=",value)
141+
}
142+
}
143+
}
144+
}

0 commit comments

Comments
 (0)