Examples of Metaphone


Examples of org.apache.commons.codec.language.Metaphone

      }
    }

    Soundex soundex = new Soundex();
    RefinedSoundex refinedSoundex = new RefinedSoundex();
    Metaphone metaphone = new Metaphone();

    double threshold;
    if (matchMode == MatchMode.STRICT) {
      threshold = STRICT_SIMILARITY_THRESHOLD;
    } else {
      threshold = LOOSE_SIMILARITY_THRESHOLD;
    }
    int soundexThreshold = (int) Math.round(threshold * 4);

    for (String similarityGroupValue : similarityGroup.getValues()) {
      boolean metaphoneEquals = metaphone.isMetaphoneEqual(value, similarityGroupValue);
      if (metaphoneEquals) {
        return true;
      }

      try {
View Full Code Here

Examples of org.apache.commons.codec.language.Metaphone

    assertNull( filter.next() )// no more tokens
  }
 
  public void testEncodes() throws Exception {
    runner( new DoubleMetaphone(), true );
    runner( new Metaphone(), true );
    runner( new Soundex(), true );
    runner( new RefinedSoundex(), true );

    runner( new DoubleMetaphone(), false );
    runner( new Metaphone(), false );
    runner( new Soundex(), false );
    runner( new RefinedSoundex(), false );
  }
View Full Code Here

Examples of org.apache.commons.codec.language.Metaphone

public class MetaphoneKeyer extends Keyer {

    private Metaphone _metaphone;

    public MetaphoneKeyer() {
        _metaphone = new Metaphone();
        _metaphone.setMaxCodeLen(2000);
    }
View Full Code Here

Examples of org.apache.commons.codec.language.Metaphone

    assertNull( filter.next() )// no more tokens
  }
 
  public void testEncodes() throws Exception {
    runner( new DoubleMetaphone(), true );
    runner( new Metaphone(), true );
    runner( new Soundex(), true );
    runner( new RefinedSoundex(), true );

    runner( new DoubleMetaphone(), false );
    runner( new Metaphone(), false );
    runner( new Soundex(), false );
    runner( new RefinedSoundex(), false );
  }
View Full Code Here

Examples of org.apache.commons.codec.language.Metaphone

import org.apache.commons.codec.language.Metaphone;

public class MetaphoneEncoder {
  public static void main(String args[]) {
    Metaphone codec = new Metaphone();
    String phrase = "";
    String encoded = "";
    for(String s : args) {
      phrase += s.toUpperCase() + " ";
      encoded += codec.encode(s) + " ";
    }
   
    System.out.println("PHRASE =" + phrase);
    System.out.println("ENCODED=" + encoded);
  }
View Full Code Here

Examples of org.apache.commons.codec.language.Metaphone

import org.apache.commons.codec.binary.Base64;

public class Encoder {
 
  public String encode(String plainText) {
    Metaphone metaphoneCodec = new Metaphone();
    List<String> encodedTokens = new ArrayList<String>();

    List<String> tokens = tokenize(plainText);
    for(String token : tokens) {
      encodedTokens.add(metaphoneCodec.encode(token));
    }
   
    String metaphone = join(encodedTokens, " ");
    byte[] base64 = Base64.encodeBase64Chunked(metaphone.getBytes());
    return new String(base64);
View Full Code Here

Examples of org.apache.commons.codec.language.Metaphone

    assertNull( filter.next() )// no more tokens
  }
 
  public void testEncodes() throws Exception {
    runner( new DoubleMetaphone(), true );
    runner( new Metaphone(), true );
    runner( new Soundex(), true );
    runner( new RefinedSoundex(), true );

    runner( new DoubleMetaphone(), false );
    runner( new Metaphone(), false );
    runner( new Soundex(), false );
    runner( new RefinedSoundex(), false );
  }
View Full Code Here

Examples of org.apache.commons.codec.language.Metaphone

* Tests {@link PhoneticFilter}
*/
public class TestPhoneticFilter extends BaseTokenStreamTestCase {
  
  public void testAlgorithms() throws Exception {
    assertAlgorithm(new Metaphone(), true, "aaa bbb ccc easgasg",
        new String[] { "A", "aaa", "B", "bbb", "KKK", "ccc", "ESKS", "easgasg" });
    assertAlgorithm(new Metaphone(), false, "aaa bbb ccc easgasg",
        new String[] { "A", "B", "KKK", "ESKS" });
   
    assertAlgorithm(new DoubleMetaphone(), true, "aaa bbb ccc easgasg",
        new String[] { "A", "aaa", "PP", "bbb", "KK", "ccc", "ASKS", "easgasg" });
    assertAlgorithm(new DoubleMetaphone(), false, "aaa bbb ccc easgasg",
View Full Code Here

Examples of org.apache.commons.codec.language.Metaphone

  }
 
  /** blast some random strings through the analyzer */
  public void testRandomStrings() throws IOException {
    Encoder encoders[] = new Encoder[] {
      new Metaphone(), new DoubleMetaphone(), new Soundex(), new RefinedSoundex(), new Caverphone()
    };
   
    for (final Encoder e : encoders) {
      Analyzer a = new ReusableAnalyzerBase() {
        @Override
View Full Code Here

Examples of org.apache.commons.codec.language.Metaphone

    }
  }
 
  public void testEmptyTerm() throws IOException {
    Encoder encoders[] = new Encoder[] {
        new Metaphone(), new DoubleMetaphone(), new Soundex(), new RefinedSoundex(), new Caverphone()
    };
    for (final Encoder e : encoders) {
      Analyzer a = new ReusableAnalyzerBase() {
        @Override
        protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.