Author: ggregory
Date: Thu Mar 8 13:33:00 2012
New Revision: 1298389
URL: http://svn.apache.org/viewvc?rev=1298389&view=rev
Log:
[CODEC-63] Implement NYSIIS. Adding Encoder class and test both in the test directory until
the encoder is fully baked. This should make it easier to patch further.
Modified:
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/NysiisTest.java
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/NysiisTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/NysiisTest.java?rev=1298389&r1=1298388&r2=1298389&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/NysiisTest.java
(original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/NysiisTest.java
Thu Mar 8 13:33:00 2012
@@ -49,6 +49,28 @@ public class NysiisTest extends StringEn
}
@Test
+ public void testBran() throws EncoderException {
+ encodeAll(new String[] { "Brian", "Brown", "Brun" }, "BRAN");
+ }
+
+ @Test
+ public void testCap() throws EncoderException {
+ this.encodeAll(new String[] { "Capp", "Cope", "Copp", "Kipp" }, "CAP");
+ }
+
+ @Test
+ public void testDad() throws EncoderException {
+ // Data Quality and Record Linkage Techniques P.121 claims this is DAN,
+ // but it should be DAD, verified also with dropby.com
+ this.encodeAll(new String[] { "Dent" }, "DAD");
+ }
+
+ @Test
+ public void testDan() throws EncoderException {
+ this.encodeAll(new String[] { "Dane", "Dean", "Dionne" }, "DAN");
+ }
+
+ @Test
public void testDropBy() throws EncoderException {
List<String[]> testValues =
Arrays.asList(
@@ -89,7 +111,7 @@ public class NysiisTest extends StringEn
* @throws EncoderException
*/
@Test
- public void testOthers() throws EncoderException {
+ public void testDropBy2() throws EncoderException {
List<String[]> testValues =
Arrays.asList(
// http://www.dropby.com/indexLF.html?content=/NYSIIS.html
@@ -125,15 +147,7 @@ public class NysiisTest extends StringEn
// If last character is S, remove it
new String[] { "JILES", "JAL" },
//new String[] { "CARRAWAY", "CARAY" },
- new String[] { "YAMADA", "YANAD" },
- // Others
- new String[] { "O'Daniel", "ODANAL" },
- new String[] { "O'Donnel", "ODANAL" },
- new String[] { "Cory", "CARY" },
- new String[] { "Corey", "CARY" },
- new String[] { "Kory", "CARY" },
- //
- new String[] { "FUZZY", "FASY" });
+ new String[] { "YAMADA", "YANAD" });
for (String[] arr : testValues) {
Assert.assertEquals("Problem with " + arr[0], arr[1], createStringEncoder(false).encode(arr[0]));
@@ -141,30 +155,30 @@ public class NysiisTest extends StringEn
}
@Test
- public void testBran() throws EncoderException {
- encodeAll(new String[] { "Brian", "Brown", "Brun" }, "BRAN");
- }
-
- @Test
- public void testCap() throws EncoderException {
- this.encodeAll(new String[] { "Capp", "Cope", "Copp", "Kipp" }, "CAP");
- }
-
- @Test
- public void testDan() throws EncoderException {
- this.encodeAll(new String[] { "Dane", "Dean", "Dionne" }, "DAN");
+ public void testFal() throws EncoderException {
+ this.encodeAll(new String[] { "Phil" }, "FAL");
}
+ /**
+ * Tests data gathered from around the internets.
+ *
+ * @throws EncoderException
+ */
@Test
- public void testDad() throws EncoderException {
- // Data Quality and Record Linkage Techniques P.121 claims this is DAN,
- // but it should be DAD, verified also with dropby.com
- this.encodeAll(new String[] { "Dent" }, "DAD");
- }
+ public void testOthers() throws EncoderException {
+ List<String[]> testValues =
+ Arrays.asList(
+ new String[] { "O'Daniel", "ODANAL" },
+ new String[] { "O'Donnel", "ODANAL" },
+ new String[] { "Cory", "CARY" },
+ new String[] { "Corey", "CARY" },
+ new String[] { "Kory", "CARY" },
+ //
+ new String[] { "FUZZY", "FASY" });
- @Test
- public void testSnat() throws EncoderException {
- this.encodeAll(new String[] { "Smith", "Schmit" }, "SNAT");
+ for (String[] arr : testValues) {
+ Assert.assertEquals("Problem with " + arr[0], arr[1], createStringEncoder(false).encode(arr[0]));
+ }
}
@Test
@@ -175,8 +189,8 @@ public class NysiisTest extends StringEn
}
@Test
- public void testFal() throws EncoderException {
- this.encodeAll(new String[] { "Phil" }, "FAL");
+ public void testSnat() throws EncoderException {
+ this.encodeAll(new String[] { "Smith", "Schmit" }, "SNAT");
}
@Test
|