Example usage for org.apache.commons.codec.language Soundex encode

List of usage examples for org.apache.commons.codec.language Soundex encode

Introduction

In this page you can find the example usage for org.apache.commons.codec.language Soundex encode.

Prototype

public String encode(String pString) 

Source Link

Document

Encodes a String using the soundex algorithm.

Usage

From source file:at.jps.sanction.core.util.TokenTool.java

public static float compareSoundex(final String text1, final String text2, final boolean fuzzy,
        final int minlen, final double fuzzyValue) {

    final Soundex encoder = new Soundex(); // TODO: in reallife make this go away
    // !!//from w w w  .ja  va  2 s.  c  om

    return (compareCheck(encoder.encode(text1), encoder.encode(text2), fuzzy, minlen, fuzzyValue));

}

From source file:com.vangent.hieos.empi.transform.SoundexTransformFunction.java

/**
 *
 * @param obj//from w w w .  j av  a2s.c  o  m
 * @return
 */
public Object transform(Object obj) {
    Soundex encoder = new Soundex();
    return encoder.encode((String) obj);
}

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//from   w  w w . jav  a2 s .c om
            .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));

}

From source file:com.medigy.persist.model.person.Person.java

@Transient
public String createSoundexName(final String name) {
    // using default US_ENGLISH_MAPPING for now
    Soundex soundex = new Soundex();
    return soundex.encode(name);
}

From source file:org.emau.icmvc.ganimed.epix.deduplication.impl.DeduplicationEngineTest.java

@Test
public void testColognePhonetic() throws EncoderException {
    Soundex sx = new Soundex();
    ColognePhonetic cp = new ColognePhonetic();
    //FellegiSunterAlgorithm fsa = new FellegiSunterAlgorithm<String>();

    String toBlock = "Karl-Heinz";
    String candidate = "Katl-Heinz";

    System.out.println("Cologne Phonetik PCODE1: " + cp.colognePhonetic(toBlock));
    System.out.println("Cologne Phonetik PCODE2: " + cp.colognePhonetic(candidate));

    System.out.println("Soundex PCODE1: " + sx.encode(toBlock));
    System.out.println("Soundex PCODE2: " + sx.encode(candidate));

    System.out.println("Soundex PCODE1: " + sx.encode(toBlock));
    System.out.println("Soundex PCODE2: " + sx.encode(candidate));

    //System.out.println("FellegiSunter PCODE1: " + fsa);

    boolean bool = cp.isEncodeEqual(toBlock, candidate);
    System.out.println("Blocking: " + toBlock + "  " + candidate + " " + bool);
    System.out.println("Decition " + bool + " " + (bool ? 1 : 0));

    /*/*from   w ww.  j  a v a  2s. c  om*/
    PreprocessingStrategy<Patient> ps = new CommonPreprocessor<Patient>();
    ps.preprocess(cp);
            
    DeduplicationStrategy<Patient> ds = new FellegiSunterAlgorithm<Patient>();
    ds.setMatchingConfiguration(matchingConfiguration);
    ds.match(toMatch, candidate)
    */
}

From source file:org.folg.names.score.CoderTest.java

public void testSoundex() throws Exception {
    Soundex soundex = new Soundex();

    assertEquals(soundex.encode("john"), soundex.encode("jim"));
    assertEquals(soundex.encode("john"), soundex.encode("june"));
    assertEquals(soundex.encode("john"), soundex.encode("jane"));
    assertNotSame(soundex.encode("john"), soundex.encode("johannes"));
    assertEquals(soundex.encode("john"), soundex.encode("johan"));
    assertNotSame(soundex.encode("johan"), soundex.encode("johannes"));
}

From source file:patientlinkage.Util.Util.java

public static String[][] readAndProcessCSV(String FileName, int records_num) {
    String[][] data1 = null;/*from  w w w.  j  av  a2 s  .  c om*/
    int properties_num = 6;
    Soundex sdx = new Soundex();

    try (CSVReader reader = new CSVReader(new FileReader(FileName))) {
        String[] nextLine;
        data1 = new String[records_num][properties_num];
        reader.readNext();
        int ind = 0;
        while ((nextLine = reader.readNext()) != null && ind < records_num) {
            data1[ind][0] = nextLine[1].toLowerCase();
            data1[ind][1] = nextLine[2].toLowerCase();
            data1[ind][2] = sdx.encode(nextLine[1]).toLowerCase();
            data1[ind][3] = sdx.encode(nextLine[2]).toLowerCase();
            data1[ind][4] = nextLine[6].replaceAll("-", "");
            data1[ind][5] = nextLine[11].replaceAll("-", "");

            ind++;

        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(PatientLinkageGadget.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(PatientLinkageGadget.class.getName()).log(Level.SEVERE, null, ex);
    }

    return data1;
}