List of usage examples for org.apache.commons.codec StringEncoderComparator compare
public int compare(Object o1, Object o2)
From source file:LanguageUsage.java
public void start() throws EncoderException, DecoderException { String word1 = "Wilson"; String word2 = "Wylson"; String foreignWord1 = "Otto"; String foreignWord2 = "Auto"; Soundex sndx = new Soundex(); DoubleMetaphone doubleMetaphone = new DoubleMetaphone(); System.err.println("Soundex Code for Wilson is: " + sndx.encode("Wilson")); System.err.println("Soundex Code for Wylson is: " + sndx.encode("Wylson")); // Use the StringEncoderComparator to compare these two Strings StringEncoderComparator comparator1 = new StringEncoderComparator(sndx); System.err/* w w w. j a va 2 s . c o m*/ .println("Are Wilson and Wylson same based on Soundex? " + comparator1.compare("Wilson", "Wylson")); System.err.println("Are Auto and Otto same based on Soundex? " + comparator1.compare("Auto", "Otto")); StringEncoderComparator comparator2 = new StringEncoderComparator(doubleMetaphone); System.err .println("Are Auto and Otto same based on DoubleMetaphone? " + comparator2.compare("Auto", "Otto")); System.err.println( "Double Metaphone primary code for Schmidt: " + doubleMetaphone.doubleMetaphone("Schmidt")); System.err.println( "Double Metaphone secondary code for Schmidt: " + doubleMetaphone.doubleMetaphone("Schmidt", true)); }