Skip to content

Commit 72c8759

Browse files
committed
Eberhard -> 01772 (not 0172) because two or more identical consecutive digits can occur if they occur after removing the "0" digits last step.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1073513 13f79535-47bb-0310-9956-ffa450edef68
1 parent 84e270e commit 72c8759

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@
165165
*
166166
* <li>
167167
* <h3>Third step:</h3>
168-
* Removal of all codes “0” except at the beginning
168+
* Removal of all codes “0” except at the beginning. This means that two or more identical consecutive digits can occur
169+
* if they occur after removing the "0" digits.
169170
*
170171
* <h4>Example:</h4>
171172
* {@code "6050750206802" => "65752682"}</li>
@@ -368,10 +369,10 @@ public String colognePhonetic(String text) {
368369

369370
if (code != '-' && (lastCode != code && (code != '0' || lastCode == '/') || code < '0' || code > '8')) {
370371
left.addRight(code);
371-
lastCode = code;
372372
}
373373

374374
lastChar = chr;
375+
lastCode = code;
375376
}
376377
return left.toString();
377378
}

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ public void testExamples() {
100100
{"weber", "317"},
101101
// {"wagner", "357"},
102102
{"becker", "147"},
103-
{"hoffmann", "036"},
103+
{"hoffmann", "0366"},
104104
{"sch\u00C4fer", "837"},
105105
{"Breschnew", "17863"},
106106
{"Wikipedia", "3412"},
107107
{"peter", "127"},
108108
{"pharma", "376"},
109-
{"mönchengladbach", "64645214"},
109+
{"mönchengladbach", "664645214"},
110110
{"deutsch", "28"},
111111
{"deutz", "28"},
112112
{"hamburg", "06174"},
@@ -118,8 +118,8 @@ public void testExamples() {
118118
{"matsch", "68"},
119119
{"matz", "68"},
120120
{"Arbeitsamt", "071862"},
121-
{"Eberhard", "0172"},
122-
{"Eberhardt", "0172"},
121+
{"Eberhard", "01772"},
122+
{"Eberhardt", "01772"},
123123
{"heithabu", "021"}};
124124
this.checkEncodings(data);
125125
}
@@ -147,8 +147,14 @@ public void testIsCologneEquals() {
147147
}
148148
}
149149

150-
public void testVariations() {
150+
public void testVariationsMeyer() {
151151
String data[] = {"Meier", "Maier", "Mair", "Meyer", "Meyr", "Mejer", "Major"};
152152
this.checkEncodingVariations("67", data);
153+
154+
}
155+
156+
public void testVariationsMella() {
157+
String data[] = {"mella", "milah", "moulla", "mellah", "muehle", "mule"};
158+
this.checkEncodingVariations("65", data);
153159
}
154160
}

0 commit comments

Comments
 (0)