@@ -225,21 +225,18 @@ func Test_AnalyzeWithSearchMode(t *testing.T) {
225
225
}
226
226
tokens := tnz .Analyze ("関西国際空港" , Search )
227
227
expected := []Token {
228
- {ID : - 1 , Surface : "BOS" },
229
- {ID : 372968 , Surface : "関西" , Start : 0 , End : 2 , Class : TokenClass (lattice .KNOWN )},
230
- {ID : 168541 , Surface : "国際" , Start : 2 , End : 4 , Class : TokenClass (lattice .KNOWN )},
231
- {ID : 307133 , Surface : "空港" , Start : 4 , End : 6 , Class : TokenClass (lattice .KNOWN )},
232
- {ID : - 1 , Surface : "EOS" , Start : 6 , End : 6 },
228
+ {Index : 0 , ID : - 1 , Surface : "BOS" },
229
+ {Index : 1 , ID : 372967 , Surface : "関西" , Start : 0 , End : 2 , Position : 0 , Class : TokenClass (lattice .KNOWN )},
230
+ {Index : 2 , ID : 168542 , Surface : "国際" , Start : 2 , End : 4 , Position : 6 , Class : TokenClass (lattice .KNOWN )},
231
+ {Index : 3 , ID : 307134 , Surface : "空港" , Start : 4 , End : 6 , Position : 12 , Class : TokenClass (lattice .KNOWN )},
232
+ {Index : 4 , ID : - 1 , Surface : "EOS" , Start : 6 , End : 6 , Position : 18 },
233
233
}
234
234
235
235
if len (tokens ) != len (expected ) {
236
236
t .Fatalf ("got %v, expected %v" , tokens , expected )
237
237
}
238
238
for i , tok := range tokens {
239
- if tok .Class != expected [i ].Class ||
240
- tok .Start != expected [i ].Start ||
241
- tok .End != expected [i ].End ||
242
- tok .Surface != expected [i ].Surface {
239
+ if tok .Index != expected [i ].Index || ! tok .Equal (expected [i ]) {
243
240
t .Errorf ("got %v, expected %v" , tok , expected [i ])
244
241
}
245
242
}
@@ -257,19 +254,15 @@ func Test_AnalyzeWithSearchModeUnknown(t *testing.T) {
257
254
258
255
tokens := tnz .Analyze ("ポポピ" , Search )
259
256
expected := []Token {
260
- {ID : - 1 , Surface : "BOS" },
261
- {ID : 34 , Surface : "ポポピ" , Start : 0 , End : 3 , Class : TokenClass (lattice .UNKNOWN )},
262
- {ID : - 1 , Surface : "EOS" , Start : 3 , End : 3 },
257
+ {Index : 0 , ID : - 1 , Surface : "BOS" },
258
+ {Index : 1 , ID : 34 , Surface : "ポポピ" , Start : 0 , End : 3 , Class : TokenClass (lattice .UNKNOWN )},
259
+ {Index : 2 , ID : - 1 , Surface : "EOS" , Start : 3 , End : 3 , Position : 9 },
263
260
}
264
261
if len (tokens ) != len (expected ) {
265
262
t .Fatalf ("got %v, expected %v" , tokens , expected )
266
263
}
267
264
for i , tok := range tokens {
268
- if tok .ID != expected [i ].ID ||
269
- tok .Class != expected [i ].Class ||
270
- tok .Start != expected [i ].Start ||
271
- tok .End != expected [i ].End ||
272
- tok .Surface != expected [i ].Surface {
265
+ if tok .Index != expected [i ].Index || ! tok .Equal (expected [i ]) {
273
266
t .Errorf ("got %v, expected %v" , tok , expected [i ])
274
267
}
275
268
}
@@ -287,18 +280,14 @@ func Test_AnalyzeWithExtendedModeEmpty(t *testing.T) {
287
280
288
281
tokens := tnz .Analyze ("" , Extended )
289
282
expected := []Token {
290
- {ID : - 1 , Surface : "BOS" },
291
- {ID : - 1 , Surface : "EOS" },
283
+ {Index : 0 , ID : - 1 , Surface : "BOS" },
284
+ {Index : 1 , ID : - 1 , Surface : "EOS" },
292
285
}
293
286
if len (tokens ) != len (expected ) {
294
287
t .Fatalf ("got %v, expected %v" , tokens , expected )
295
288
}
296
289
for i , tok := range tokens {
297
- if tok .ID != expected [i ].ID ||
298
- tok .Class != expected [i ].Class ||
299
- tok .Start != expected [i ].Start ||
300
- tok .End != expected [i ].End ||
301
- tok .Surface != expected [i ].Surface {
290
+ if tok .Index != expected [i ].Index || ! tok .Equal (expected [i ]) {
302
291
t .Errorf ("got %v, expected %v" , tok , expected [i ])
303
292
}
304
293
}
@@ -316,20 +305,17 @@ func Test_AnalyzeWithExtendedMode(t *testing.T) {
316
305
317
306
tokens := tnz .Analyze ("関西国際空港" , Extended )
318
307
expected := []Token {
319
- {ID : - 1 , Surface : "BOS" },
320
- {ID : 372968 , Surface : "関西" , Start : 0 , End : 2 , Class : TokenClass (lattice .KNOWN )},
321
- {ID : 168541 , Surface : "国際" , Start : 2 , End : 4 , Class : TokenClass (lattice .KNOWN )},
322
- {ID : 307133 , Surface : "空港" , Start : 4 , End : 6 , Class : TokenClass (lattice .KNOWN )},
323
- {ID : - 1 , Surface : "EOS" , Start : 6 , End : 6 },
308
+ {Index : 0 , ID : - 1 , Surface : "BOS" },
309
+ {Index : 1 , ID : 372967 , Surface : "関西" , Start : 0 , End : 2 , Position : 0 , Class : TokenClass (lattice .KNOWN )},
310
+ {Index : 2 , ID : 168542 , Surface : "国際" , Start : 2 , End : 4 , Position : 6 , Class : TokenClass (lattice .KNOWN )},
311
+ {Index : 3 , ID : 307134 , Surface : "空港" , Start : 4 , End : 6 , Position : 12 , Class : TokenClass (lattice .KNOWN )},
312
+ {Index : 4 , ID : - 1 , Surface : "EOS" , Start : 6 , End : 6 , Position : 18 },
324
313
}
325
314
if len (tokens ) != len (expected ) {
326
315
t .Fatalf ("got %v, expected %v" , tokens , expected )
327
316
}
328
317
for i , tok := range tokens {
329
- if tok .Class != expected [i ].Class ||
330
- tok .Start != expected [i ].Start ||
331
- tok .End != expected [i ].End ||
332
- tok .Surface != expected [i ].Surface {
318
+ if tok .Index != expected [i ].Index || ! tok .Equal (expected [i ]) {
333
319
t .Errorf ("got %v, expected %v" , tok , expected [i ])
334
320
}
335
321
}
@@ -347,21 +333,17 @@ func Test_AnalyzeWithExtendedModeUnknown(t *testing.T) {
347
333
348
334
tokens := tnz .Analyze ("ポポピ" , Extended )
349
335
expected := []Token {
350
- {ID : - 1 , Surface : "BOS" },
351
- {ID : 34 , Surface : "ポ" , Start : 0 , End : 1 , Class : TokenClass (lattice .DUMMY )},
352
- {ID : 34 , Surface : "ポ" , Start : 1 , End : 2 , Class : TokenClass (lattice .DUMMY )},
353
- {ID : 34 , Surface : "ピ" , Start : 2 , End : 3 , Class : TokenClass (lattice .DUMMY )},
354
- {ID : - 1 , Surface : "EOS" , Start : 3 , End : 3 },
336
+ {Index : 0 , ID : - 1 , Surface : "BOS" },
337
+ {Index : 1 , ID : 34 , Surface : "ポ" , Start : 0 , End : 1 , Position : 0 , Class : TokenClass (lattice .DUMMY )},
338
+ {Index : 2 , ID : 34 , Surface : "ポ" , Start : 1 , End : 2 , Position : 3 , Class : TokenClass (lattice .DUMMY )},
339
+ {Index : 3 , ID : 34 , Surface : "ピ" , Start : 2 , End : 3 , Position : 6 , Class : TokenClass (lattice .DUMMY )},
340
+ {Index : 4 , ID : - 1 , Surface : "EOS" , Start : 3 , End : 3 , Position : 9 },
355
341
}
356
342
if len (tokens ) != len (expected ) {
357
343
t .Fatalf ("got %v, expected %v" , tokens , expected )
358
344
}
359
345
for i , tok := range tokens {
360
- if tok .ID != expected [i ].ID ||
361
- tok .Class != expected [i ].Class ||
362
- tok .Start != expected [i ].Start ||
363
- tok .End != expected [i ].End ||
364
- tok .Surface != expected [i ].Surface {
346
+ if tok .Index != expected [i ].Index || ! tok .Equal (expected [i ]) {
365
347
t .Errorf ("got %v, expected %v" , tok , expected [i ])
366
348
}
367
349
}
0 commit comments