@@ -51,53 +51,94 @@ func Test_Benchmark(t *testing.T) {
51
51
fmt .Println (testing .Benchmark (TextSliceToString ))
52
52
}
53
53
54
-
55
- func Test_Token_TextEquals (t * testing.T ){
54
+ func Test_Token_TextEquals (t * testing.T ) {
56
55
token := Token {
57
- text :[]Text {
56
+ text : []Text {
58
57
[]byte ("one" ),
59
58
[]byte ("two" ),
60
59
},
61
60
}
62
- assert .True (t ,token .TextEquals ("onetwo" ))
61
+ assert .True (t , token .TextEquals ("onetwo" ))
63
62
}
64
63
65
- func Test_Token_TextEquals_CN (t * testing.T ){
64
+ func Test_Token_TextEquals_CN (t * testing.T ) {
66
65
token := Token {
67
- text :[]Text {
66
+ text : []Text {
68
67
[]byte ("中国" ),
69
68
[]byte ("文字" ),
70
69
},
71
70
}
72
- assert .True (t ,token .TextEquals ("中国文字" ))
71
+ assert .True (t , token .TextEquals ("中国文字" ))
73
72
}
74
73
75
- func Test_Token_TextNotEquals (t * testing.T ){
74
+ func Test_Token_TextNotEquals (t * testing.T ) {
76
75
token := Token {
77
- text :[]Text {
76
+ text : []Text {
78
77
[]byte ("one" ),
79
78
[]byte ("two" ),
80
79
},
81
80
}
82
- assert .False (t ,token .TextEquals ("one-two" ))
81
+ assert .False (t , token .TextEquals ("one-two" ))
83
82
}
84
83
85
- func Test_Token_TextNotEquals_CN (t * testing.T ){
84
+ func Test_Token_TextNotEquals_CN (t * testing.T ) {
86
85
token := Token {
87
- text :[]Text {
86
+ text : []Text {
88
87
[]byte ("中国" ),
89
88
[]byte ("文字" ),
90
89
},
91
90
}
92
- assert .False (t ,token .TextEquals ("中国文字1" ))
91
+ assert .False (t , token .TextEquals ("中国文字1" ))
93
92
}
94
93
95
- func Test_Token_TextNotEquals_CN_B (t * testing.T ){
94
+ func Test_Token_TextNotEquals_CN_B (t * testing.T ) {
96
95
token := Token {
97
- text :[]Text {
96
+ text : []Text {
98
97
[]byte ("中国" ),
99
98
[]byte ("文字" ),
100
99
},
101
100
}
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