@@ -41,7 +41,7 @@ protected Soundex createStringEncoder() {
41
41
42
42
@ Test
43
43
public void testB650 () throws EncoderException {
44
- this . checkEncodingVariations ("B650" , new String []{
44
+ checkEncodingVariations ("B650" , new String []{
45
45
"BARHAM" ,
46
46
"BARONE" ,
47
47
"BARRON" ,
@@ -86,102 +86,102 @@ public void testB650() throws EncoderException {
86
86
87
87
@ Test
88
88
public void testBadCharacters () {
89
- assertEquals ("H452" , this . getStringEncoder ().encode ("HOL>MES" ));
89
+ assertEquals ("H452" , getStringEncoder ().encode ("HOL>MES" ));
90
90
91
91
}
92
92
93
93
@ Test
94
94
public void testDifference () throws EncoderException {
95
95
// Edge cases
96
- assertEquals (0 , this . getStringEncoder ().difference (null , null ));
97
- assertEquals (0 , this . getStringEncoder ().difference ("" , "" ));
98
- assertEquals (0 , this . getStringEncoder ().difference (" " , " " ));
96
+ assertEquals (0 , getStringEncoder ().difference (null , null ));
97
+ assertEquals (0 , getStringEncoder ().difference ("" , "" ));
98
+ assertEquals (0 , getStringEncoder ().difference (" " , " " ));
99
99
// Normal cases
100
- assertEquals (4 , this . getStringEncoder ().difference ("Smith" , "Smythe" ));
101
- assertEquals (2 , this . getStringEncoder ().difference ("Ann" , "Andrew" ));
102
- assertEquals (1 , this . getStringEncoder ().difference ("Margaret" , "Andrew" ));
103
- assertEquals (0 , this . getStringEncoder ().difference ("Janet" , "Margaret" ));
100
+ assertEquals (4 , getStringEncoder ().difference ("Smith" , "Smythe" ));
101
+ assertEquals (2 , getStringEncoder ().difference ("Ann" , "Andrew" ));
102
+ assertEquals (1 , getStringEncoder ().difference ("Margaret" , "Andrew" ));
103
+ assertEquals (0 , getStringEncoder ().difference ("Janet" , "Margaret" ));
104
104
// Examples from https://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_de-dz_8co5.asp
105
- assertEquals (4 , this . getStringEncoder ().difference ("Green" , "Greene" ));
106
- assertEquals (0 , this . getStringEncoder ().difference ("Blotchet-Halls" , "Greene" ));
105
+ assertEquals (4 , getStringEncoder ().difference ("Green" , "Greene" ));
106
+ assertEquals (0 , getStringEncoder ().difference ("Blotchet-Halls" , "Greene" ));
107
107
// Examples from https://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_setu-sus_3o6w.asp
108
- assertEquals (4 , this . getStringEncoder ().difference ("Smith" , "Smythe" ));
109
- assertEquals (4 , this . getStringEncoder ().difference ("Smithers" , "Smythers" ));
110
- assertEquals (2 , this . getStringEncoder ().difference ("Anothers" , "Brothers" ));
108
+ assertEquals (4 , getStringEncoder ().difference ("Smith" , "Smythe" ));
109
+ assertEquals (4 , getStringEncoder ().difference ("Smithers" , "Smythers" ));
110
+ assertEquals (2 , getStringEncoder ().difference ("Anothers" , "Brothers" ));
111
111
}
112
112
113
113
@ Test
114
114
public void testEncodeBasic () {
115
- assertEquals ("T235" , this . getStringEncoder ().encode ("testing" ));
116
- assertEquals ("T000" , this . getStringEncoder ().encode ("The" ));
117
- assertEquals ("Q200" , this . getStringEncoder ().encode ("quick" ));
118
- assertEquals ("B650" , this . getStringEncoder ().encode ("brown" ));
119
- assertEquals ("F200" , this . getStringEncoder ().encode ("fox" ));
120
- assertEquals ("J513" , this . getStringEncoder ().encode ("jumped" ));
121
- assertEquals ("O160" , this . getStringEncoder ().encode ("over" ));
122
- assertEquals ("T000" , this . getStringEncoder ().encode ("the" ));
123
- assertEquals ("L200" , this . getStringEncoder ().encode ("lazy" ));
124
- assertEquals ("D200" , this . getStringEncoder ().encode ("dogs" ));
115
+ assertEquals ("T235" , getStringEncoder ().encode ("testing" ));
116
+ assertEquals ("T000" , getStringEncoder ().encode ("The" ));
117
+ assertEquals ("Q200" , getStringEncoder ().encode ("quick" ));
118
+ assertEquals ("B650" , getStringEncoder ().encode ("brown" ));
119
+ assertEquals ("F200" , getStringEncoder ().encode ("fox" ));
120
+ assertEquals ("J513" , getStringEncoder ().encode ("jumped" ));
121
+ assertEquals ("O160" , getStringEncoder ().encode ("over" ));
122
+ assertEquals ("T000" , getStringEncoder ().encode ("the" ));
123
+ assertEquals ("L200" , getStringEncoder ().encode ("lazy" ));
124
+ assertEquals ("D200" , getStringEncoder ().encode ("dogs" ));
125
125
}
126
126
127
127
/**
128
128
* Examples from http://www.bradandkathy.com/genealogy/overviewofsoundex.html
129
129
*/
130
130
@ Test
131
131
public void testEncodeBatch2 () {
132
- assertEquals ("A462" , this . getStringEncoder ().encode ("Allricht" ));
133
- assertEquals ("E166" , this . getStringEncoder ().encode ("Eberhard" ));
134
- assertEquals ("E521" , this . getStringEncoder ().encode ("Engebrethson" ));
135
- assertEquals ("H512" , this . getStringEncoder ().encode ("Heimbach" ));
136
- assertEquals ("H524" , this . getStringEncoder ().encode ("Hanselmann" ));
137
- assertEquals ("H431" , this . getStringEncoder ().encode ("Hildebrand" ));
138
- assertEquals ("K152" , this . getStringEncoder ().encode ("Kavanagh" ));
139
- assertEquals ("L530" , this . getStringEncoder ().encode ("Lind" ));
140
- assertEquals ("L222" , this . getStringEncoder ().encode ("Lukaschowsky" ));
141
- assertEquals ("M235" , this . getStringEncoder ().encode ("McDonnell" ));
142
- assertEquals ("M200" , this . getStringEncoder ().encode ("McGee" ));
143
- assertEquals ("O155" , this . getStringEncoder ().encode ("Opnian" ));
144
- assertEquals ("O155" , this . getStringEncoder ().encode ("Oppenheimer" ));
145
- assertEquals ("R355" , this . getStringEncoder ().encode ("Riedemanas" ));
146
- assertEquals ("Z300" , this . getStringEncoder ().encode ("Zita" ));
147
- assertEquals ("Z325" , this . getStringEncoder ().encode ("Zitzmeinn" ));
132
+ assertEquals ("A462" , getStringEncoder ().encode ("Allricht" ));
133
+ assertEquals ("E166" , getStringEncoder ().encode ("Eberhard" ));
134
+ assertEquals ("E521" , getStringEncoder ().encode ("Engebrethson" ));
135
+ assertEquals ("H512" , getStringEncoder ().encode ("Heimbach" ));
136
+ assertEquals ("H524" , getStringEncoder ().encode ("Hanselmann" ));
137
+ assertEquals ("H431" , getStringEncoder ().encode ("Hildebrand" ));
138
+ assertEquals ("K152" , getStringEncoder ().encode ("Kavanagh" ));
139
+ assertEquals ("L530" , getStringEncoder ().encode ("Lind" ));
140
+ assertEquals ("L222" , getStringEncoder ().encode ("Lukaschowsky" ));
141
+ assertEquals ("M235" , getStringEncoder ().encode ("McDonnell" ));
142
+ assertEquals ("M200" , getStringEncoder ().encode ("McGee" ));
143
+ assertEquals ("O155" , getStringEncoder ().encode ("Opnian" ));
144
+ assertEquals ("O155" , getStringEncoder ().encode ("Oppenheimer" ));
145
+ assertEquals ("R355" , getStringEncoder ().encode ("Riedemanas" ));
146
+ assertEquals ("Z300" , getStringEncoder ().encode ("Zita" ));
147
+ assertEquals ("Z325" , getStringEncoder ().encode ("Zitzmeinn" ));
148
148
}
149
149
150
150
/**
151
151
* Examples from http://www.archives.gov/research_room/genealogy/census/soundex.html
152
152
*/
153
153
@ Test
154
154
public void testEncodeBatch3 () {
155
- assertEquals ("W252" , this . getStringEncoder ().encode ("Washington" ));
156
- assertEquals ("L000" , this . getStringEncoder ().encode ("Lee" ));
157
- assertEquals ("G362" , this . getStringEncoder ().encode ("Gutierrez" ));
158
- assertEquals ("P236" , this . getStringEncoder ().encode ("Pfister" ));
159
- assertEquals ("J250" , this . getStringEncoder ().encode ("Jackson" ));
160
- assertEquals ("T522" , this . getStringEncoder ().encode ("Tymczak" ));
155
+ assertEquals ("W252" , getStringEncoder ().encode ("Washington" ));
156
+ assertEquals ("L000" , getStringEncoder ().encode ("Lee" ));
157
+ assertEquals ("G362" , getStringEncoder ().encode ("Gutierrez" ));
158
+ assertEquals ("P236" , getStringEncoder ().encode ("Pfister" ));
159
+ assertEquals ("J250" , getStringEncoder ().encode ("Jackson" ));
160
+ assertEquals ("T522" , getStringEncoder ().encode ("Tymczak" ));
161
161
// For VanDeusen: D-250 (D, 2 for the S, 5 for the N, 0 added) is also
162
162
// possible.
163
- assertEquals ("V532" , this . getStringEncoder ().encode ("VanDeusen" ));
163
+ assertEquals ("V532" , getStringEncoder ().encode ("VanDeusen" ));
164
164
}
165
165
166
166
/**
167
167
* Examples from: http://www.myatt.demon.co.uk/sxalg.htm
168
168
*/
169
169
@ Test
170
170
public void testEncodeBatch4 () {
171
- assertEquals ("H452" , this . getStringEncoder ().encode ("HOLMES" ));
172
- assertEquals ("A355" , this . getStringEncoder ().encode ("ADOMOMI" ));
173
- assertEquals ("V536" , this . getStringEncoder ().encode ("VONDERLEHR" ));
174
- assertEquals ("B400" , this . getStringEncoder ().encode ("BALL" ));
175
- assertEquals ("S000" , this . getStringEncoder ().encode ("SHAW" ));
176
- assertEquals ("J250" , this . getStringEncoder ().encode ("JACKSON" ));
177
- assertEquals ("S545" , this . getStringEncoder ().encode ("SCANLON" ));
178
- assertEquals ("S532" , this . getStringEncoder ().encode ("SAINTJOHN" ));
171
+ assertEquals ("H452" , getStringEncoder ().encode ("HOLMES" ));
172
+ assertEquals ("A355" , getStringEncoder ().encode ("ADOMOMI" ));
173
+ assertEquals ("V536" , getStringEncoder ().encode ("VONDERLEHR" ));
174
+ assertEquals ("B400" , getStringEncoder ().encode ("BALL" ));
175
+ assertEquals ("S000" , getStringEncoder ().encode ("SHAW" ));
176
+ assertEquals ("J250" , getStringEncoder ().encode ("JACKSON" ));
177
+ assertEquals ("S545" , getStringEncoder ().encode ("SCANLON" ));
178
+ assertEquals ("S532" , getStringEncoder ().encode ("SAINTJOHN" ));
179
179
180
180
}
181
181
182
182
@ Test
183
183
public void testEncodeIgnoreApostrophes () throws EncoderException {
184
- this . checkEncodingVariations ("O165" , new String []{
184
+ checkEncodingVariations ("O165" , new String []{
185
185
"OBrien" ,
186
186
"'OBrien" ,
187
187
"O'Brien" ,
@@ -198,7 +198,7 @@ public void testEncodeIgnoreApostrophes() throws EncoderException {
198
198
* @throws EncoderException for some failure scenarios */
199
199
@ Test
200
200
public void testEncodeIgnoreHyphens () throws EncoderException {
201
- this . checkEncodingVariations ("K525" , new String []{
201
+ checkEncodingVariations ("K525" , new String []{
202
202
"KINGSMITH" ,
203
203
"-KINGSMITH" ,
204
204
"K-INGSMITH" ,
@@ -214,7 +214,7 @@ public void testEncodeIgnoreHyphens() throws EncoderException {
214
214
215
215
@ Test
216
216
public void testEncodeIgnoreTrimmable () {
217
- assertEquals ("W252" , this . getStringEncoder ().encode (" \t \n \r Washington \t \n \r " ));
217
+ assertEquals ("W252" , getStringEncoder ().encode (" \t \n \r Washington \t \n \r " ));
218
218
}
219
219
220
220
@ Test
@@ -240,10 +240,10 @@ public void testHWRuleEx1() {
240
240
// http://www.archives.gov/research_room/genealogy/census/soundex.html:
241
241
// Ashcraft is coded A-261 (A, 2 for the S, C ignored, 6 for the R, 1
242
242
// for the F). It is not coded A-226.
243
- assertEquals ("A261" , this . getStringEncoder ().encode ("Ashcraft" ));
244
- assertEquals ("A261" , this . getStringEncoder ().encode ("Ashcroft" ));
245
- assertEquals ("Y330" , this . getStringEncoder ().encode ("yehudit" ));
246
- assertEquals ("Y330" , this . getStringEncoder ().encode ("yhwdyt" ));
243
+ assertEquals ("A261" , getStringEncoder ().encode ("Ashcraft" ));
244
+ assertEquals ("A261" , getStringEncoder ().encode ("Ashcroft" ));
245
+ assertEquals ("Y330" , getStringEncoder ().encode ("yehudit" ));
246
+ assertEquals ("Y330" , getStringEncoder ().encode ("yhwdyt" ));
247
247
}
248
248
249
249
/**
@@ -253,8 +253,8 @@ public void testHWRuleEx1() {
253
253
*/
254
254
@ Test
255
255
public void testHWRuleEx2 () {
256
- assertEquals ("B312" , this . getStringEncoder ().encode ("BOOTHDAVIS" ));
257
- assertEquals ("B312" , this . getStringEncoder ().encode ("BOOTH-DAVIS" ));
256
+ assertEquals ("B312" , getStringEncoder ().encode ("BOOTHDAVIS" ));
257
+ assertEquals ("B312" , getStringEncoder ().encode ("BOOTH-DAVIS" ));
258
258
}
259
259
260
260
/**
@@ -263,10 +263,10 @@ public void testHWRuleEx2() {
263
263
* @throws EncoderException for some failure scenarios */
264
264
@ Test
265
265
public void testHWRuleEx3 () throws EncoderException {
266
- assertEquals ("S460" , this . getStringEncoder ().encode ("Sgler" ));
267
- assertEquals ("S460" , this . getStringEncoder ().encode ("Swhgler" ));
266
+ assertEquals ("S460" , getStringEncoder ().encode ("Sgler" ));
267
+ assertEquals ("S460" , getStringEncoder ().encode ("Swhgler" ));
268
268
// Also S460:
269
- this . checkEncodingVariations ("S460" , new String []{
269
+ checkEncodingVariations ("S460" , new String []{
270
270
"SAILOR" ,
271
271
"SALYER" ,
272
272
"SAYLOR" ,
@@ -291,8 +291,8 @@ public void testHWRuleEx3() throws EncoderException {
291
291
*/
292
292
@ Test
293
293
public void testMsSqlServer1 () {
294
- assertEquals ("S530" , this . getStringEncoder ().encode ("Smith" ));
295
- assertEquals ("S530" , this . getStringEncoder ().encode ("Smythe" ));
294
+ assertEquals ("S530" , getStringEncoder ().encode ("Smith" ));
295
+ assertEquals ("S530" , getStringEncoder ().encode ("Smythe" ));
296
296
}
297
297
298
298
/**
@@ -303,23 +303,23 @@ public void testMsSqlServer1() {
303
303
* @throws EncoderException for some failure scenarios */
304
304
@ Test
305
305
public void testMsSqlServer2 () throws EncoderException {
306
- this . checkEncodingVariations ("E625" , new String []{"Erickson" , "Erickson" , "Erikson" , "Ericson" , "Ericksen" , "Ericsen" });
306
+ checkEncodingVariations ("E625" , new String []{"Erickson" , "Erickson" , "Erikson" , "Ericson" , "Ericksen" , "Ericsen" });
307
307
}
308
308
309
309
/**
310
310
* Examples for MS SQLServer from https://databases.about.com/library/weekly/aa042901a.htm
311
311
*/
312
312
@ Test
313
313
public void testMsSqlServer3 () {
314
- assertEquals ("A500" , this . getStringEncoder ().encode ("Ann" ));
315
- assertEquals ("A536" , this . getStringEncoder ().encode ("Andrew" ));
316
- assertEquals ("J530" , this . getStringEncoder ().encode ("Janet" ));
317
- assertEquals ("M626" , this . getStringEncoder ().encode ("Margaret" ));
318
- assertEquals ("S315" , this . getStringEncoder ().encode ("Steven" ));
319
- assertEquals ("M240" , this . getStringEncoder ().encode ("Michael" ));
320
- assertEquals ("R163" , this . getStringEncoder ().encode ("Robert" ));
321
- assertEquals ("L600" , this . getStringEncoder ().encode ("Laura" ));
322
- assertEquals ("A500" , this . getStringEncoder ().encode ("Anne" ));
314
+ assertEquals ("A500" , getStringEncoder ().encode ("Ann" ));
315
+ assertEquals ("A536" , getStringEncoder ().encode ("Andrew" ));
316
+ assertEquals ("J530" , getStringEncoder ().encode ("Janet" ));
317
+ assertEquals ("M626" , getStringEncoder ().encode ("Margaret" ));
318
+ assertEquals ("S315" , getStringEncoder ().encode ("Steven" ));
319
+ assertEquals ("M240" , getStringEncoder ().encode ("Michael" ));
320
+ assertEquals ("R163" , getStringEncoder ().encode ("Robert" ));
321
+ assertEquals ("L600" , getStringEncoder ().encode ("Laura" ));
322
+ assertEquals ("A500" , getStringEncoder ().encode ("Anne" ));
323
323
}
324
324
325
325
/**
@@ -383,12 +383,12 @@ public void testUsEnglishStatic() {
383
383
*/
384
384
@ Test
385
385
public void testUsMappingEWithAcute () {
386
- assertEquals ("E000" , this . getStringEncoder ().encode ("e" ));
386
+ assertEquals ("E000" , getStringEncoder ().encode ("e" ));
387
387
if (Character .isLetter ('\u00e9' )) { // e-acute
388
388
// uppercase E-acute
389
389
assertThrows (IllegalArgumentException .class , () -> getStringEncoder ().encode ("\u00e9 " ));
390
390
} else {
391
- assertEquals ("" , this . getStringEncoder ().encode ("\u00e9 " ));
391
+ assertEquals ("" , getStringEncoder ().encode ("\u00e9 " ));
392
392
}
393
393
}
394
394
@@ -399,12 +399,12 @@ public void testUsMappingEWithAcute() {
399
399
*/
400
400
@ Test
401
401
public void testUsMappingOWithDiaeresis () {
402
- assertEquals ("O000" , this . getStringEncoder ().encode ("o" ));
402
+ assertEquals ("O000" , getStringEncoder ().encode ("o" ));
403
403
if (Character .isLetter ('\u00f6' )) { // o-umlaut
404
404
// uppercase O-umlaut
405
405
assertThrows (IllegalArgumentException .class , () -> getStringEncoder ().encode ("\u00f6 " ));
406
406
} else {
407
- assertEquals ("" , this . getStringEncoder ().encode ("\u00f6 " ));
407
+ assertEquals ("" , getStringEncoder ().encode ("\u00f6 " ));
408
408
}
409
409
}
410
410
@@ -413,11 +413,11 @@ public void testUsMappingOWithDiaeresis() {
413
413
*/
414
414
@ Test
415
415
public void testWikipediaAmericanSoundex () {
416
- assertEquals ("R163" , this . getStringEncoder ().encode ("Robert" ));
417
- assertEquals ("R163" , this . getStringEncoder ().encode ("Rupert" ));
418
- assertEquals ("A261" , this . getStringEncoder ().encode ("Ashcraft" ));
419
- assertEquals ("A261" , this . getStringEncoder ().encode ("Ashcroft" ));
420
- assertEquals ("T522" , this . getStringEncoder ().encode ("Tymczak" ));
421
- assertEquals ("P236" , this . getStringEncoder ().encode ("Pfister" ));
416
+ assertEquals ("R163" , getStringEncoder ().encode ("Robert" ));
417
+ assertEquals ("R163" , getStringEncoder ().encode ("Rupert" ));
418
+ assertEquals ("A261" , getStringEncoder ().encode ("Ashcraft" ));
419
+ assertEquals ("A261" , getStringEncoder ().encode ("Ashcroft" ));
420
+ assertEquals ("T522" , getStringEncoder ().encode ("Tymczak" ));
421
+ assertEquals ("P236" , getStringEncoder ().encode ("Pfister" ));
422
422
}
423
423
}
0 commit comments