Skip to content

Commit 41c68e9

Browse files
committed
[CODEC-117] Caverphone encodes names starting and ending with "mb" incorrectly.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1075947 13f79535-47bb-0310-9956-ffa450edef68
1 parent 2a8fd84 commit 41c68e9

2 files changed

Lines changed: 85 additions & 78 deletions

File tree

src/java/org/apache/commons/codec/language/Caverphone.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public String caverphone(String txt) {
7171
txt = txt.replaceAll("^enough", "enou2f"); // 2.0 only
7272
txt = txt.replaceAll("^trough", "trou2f"); // 2.0 only - note the spec says ^enough here again, c+p error I assume
7373
txt = txt.replaceAll("^gn", "2n");
74-
txt = txt.replaceAll("^mb", "m2");
74+
75+
// End
76+
txt = txt.replaceAll("mb$", "m2");
7577

7678
// 4. Handle replacements
7779
txt = txt.replaceAll("cq", "2q");

src/test/org/apache/commons/codec/language/CaverphoneTest.java

Lines changed: 82 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -164,83 +164,6 @@ public void testDavidHoodRevisitedRandomNameKLN1111111() throws EncoderException
164164
"Xylon"});
165165
}
166166

167-
/**
168-
* See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
169-
*
170-
* @throws EncoderException
171-
*/
172-
public void testDavidHoodRevisitedRandomNameTTA1111111() throws EncoderException {
173-
this.checkEncodingVariations("TTA1111111", new String[]{
174-
"Darda",
175-
"Datha",
176-
"Dedie",
177-
"Deedee",
178-
"Deerdre",
179-
"Deidre",
180-
"Deirdre",
181-
"Detta",
182-
"Didi",
183-
"Didier",
184-
"Dido",
185-
"Dierdre",
186-
"Dieter",
187-
"Dita",
188-
"Ditter",
189-
"Dodi",
190-
"Dodie",
191-
"Dody",
192-
"Doherty",
193-
"Dorthea",
194-
"Dorthy",
195-
"Doti",
196-
"Dotti",
197-
"Dottie",
198-
"Dotty",
199-
"Doty",
200-
"Doughty",
201-
"Douty",
202-
"Dowdell",
203-
"Duthie",
204-
"Tada",
205-
"Taddeo",
206-
"Tadeo",
207-
"Tadio",
208-
"Tati",
209-
"Teador",
210-
"Tedda",
211-
"Tedder",
212-
"Teddi",
213-
"Teddie",
214-
"Teddy",
215-
"Tedi",
216-
"Tedie",
217-
"Teeter",
218-
"Teodoor",
219-
"Teodor",
220-
"Terti",
221-
"Theda",
222-
"Theodor",
223-
"Theodore",
224-
"Theta",
225-
"Thilda",
226-
"Thordia",
227-
"Tilda",
228-
"Tildi",
229-
"Tildie",
230-
"Tildy",
231-
"Tita",
232-
"Tito",
233-
"Tjader",
234-
"Toddie",
235-
"Toddy",
236-
"Torto",
237-
"Tuddor",
238-
"Tudor",
239-
"Turtle",
240-
"Tuttle",
241-
"Tutto"});
242-
}
243-
244167
/**
245168
* See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
246169
*
@@ -319,6 +242,83 @@ public void testDavidHoodRevisitedRandomNameTN11111111() throws EncoderException
319242
"Tyne"});
320243
}
321244

245+
/**
246+
* See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
247+
*
248+
* @throws EncoderException
249+
*/
250+
public void testDavidHoodRevisitedRandomNameTTA1111111() throws EncoderException {
251+
this.checkEncodingVariations("TTA1111111", new String[]{
252+
"Darda",
253+
"Datha",
254+
"Dedie",
255+
"Deedee",
256+
"Deerdre",
257+
"Deidre",
258+
"Deirdre",
259+
"Detta",
260+
"Didi",
261+
"Didier",
262+
"Dido",
263+
"Dierdre",
264+
"Dieter",
265+
"Dita",
266+
"Ditter",
267+
"Dodi",
268+
"Dodie",
269+
"Dody",
270+
"Doherty",
271+
"Dorthea",
272+
"Dorthy",
273+
"Doti",
274+
"Dotti",
275+
"Dottie",
276+
"Dotty",
277+
"Doty",
278+
"Doughty",
279+
"Douty",
280+
"Dowdell",
281+
"Duthie",
282+
"Tada",
283+
"Taddeo",
284+
"Tadeo",
285+
"Tadio",
286+
"Tati",
287+
"Teador",
288+
"Tedda",
289+
"Tedder",
290+
"Teddi",
291+
"Teddie",
292+
"Teddy",
293+
"Tedi",
294+
"Tedie",
295+
"Teeter",
296+
"Teodoor",
297+
"Teodor",
298+
"Terti",
299+
"Theda",
300+
"Theodor",
301+
"Theodore",
302+
"Theta",
303+
"Thilda",
304+
"Thordia",
305+
"Tilda",
306+
"Tildi",
307+
"Tildie",
308+
"Tildy",
309+
"Tita",
310+
"Tito",
311+
"Tjader",
312+
"Toddie",
313+
"Toddy",
314+
"Torto",
315+
"Tuddor",
316+
"Tudor",
317+
"Turtle",
318+
"Tuttle",
319+
"Tutto"});
320+
}
321+
322322
/**
323323
* See http://caversham.otago.ac.nz/files/working/ctp150804.pdf
324324
*
@@ -330,6 +330,11 @@ public void testDavidHoodRevisitedRandomWords() throws EncoderException {
330330
this.checkEncodingVariations("APA1111111", new String[]{"able", "appear"});
331331
}
332332

333+
public void testEndMb() throws EncoderException {
334+
String[][] data = {{"mb", "M111111111"}, {"mbmb", "MPM1111111"}};
335+
this.checkEncodings(data);
336+
}
337+
333338
// Caverphone Revisited
334339
public void testIsCaverphoneEquals() {
335340
Caverphone caverphone = new Caverphone();

0 commit comments

Comments
 (0)