Examples of DoubleMetaphone

@author Benjamin Walstrum @author Gary Gregory @version $Id: DoubleMetaphone.java,v 1.14 2003/11/07 23:12:54 ggregory Exp $
  • org.elasticsearch.common.codec.language.DoubleMetaphone

  • Examples of org.apache.commons.codec.language.DoubleMetaphone

        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",
            new String[] { "A", "PP", "KK", "ASKS" });
       
        assertAlgorithm(new Soundex(), true, "aaa bbb ccc easgasg",
            new String[] { "A000", "aaa", "B000", "bbb", "C000", "ccc", "E220", "easgasg" });
        assertAlgorithm(new Soundex(), false, "aaa bbb ccc easgasg",
    View Full Code Here

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

      }
     
      /** 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.DoubleMetaphone

        }
      }
     
      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

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

      public String[] computeAttributeProposals(final QualifiedName currentName, Collection<IEObjectDescription> descs,
          PPSearchPath searchPath) {
        if(currentName.getSegmentCount() < 2)
          return new String[0];

        final DoubleMetaphone encoder = new DoubleMetaphone();
        final String metaphoneName = encoder.encode(currentName.getLastSegment());

        Collection<String> proposals = generateAttributeCandidates(currentName, descs, searchPath);
        // propose all, but sort them based on likeness

        String[] result = new String[proposals.size()];
    View Full Code Here

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

          return new String[0];

        // compute the 5 best matches and only accept if score <= 5
        ScoreKeeper<IEObjectDescription> tracker = new ScoreKeeper<IEObjectDescription>(5, false, 5);
        // List<IEObjectDescription> metaphoneAlike = Lists.newArrayList();
        final DoubleMetaphone encoder = new DoubleMetaphone();
        final String metaphoneName = encoder.encode(currentName);

        for(IEObjectDescription d : descs) {
          EClass c = d.getEClass();
          typeok: if(types != null && types.length > 0) {
            for(EClass wanted : types)
              if((wanted == c || wanted.isSuperTypeOf(c)))
                break typeok;
            continue;
          }
          // filter based on path visibility
          if(searchPath.searchIndexOf(d) == -1)
            continue; // not visible according to path

          String candidateName = converter.toString(d.getName());
          tracker.addScore(StringUtils.getLevenshteinDistance(currentName, candidateName), d);
          String candidateMetaphone = encoder.encode(candidateName);
          // metaphone matches are scored on the pronounciation distance
          if(metaphoneName.equals(candidateMetaphone) //
              ||
              candidateMetaphone.startsWith(metaphoneName) //
              || candidateMetaphone.endsWith(metaphoneName) //
    View Full Code Here

    Examples of org.elasticsearch.common.codec.language.DoubleMetaphone

            } else if ("refined_soundex".equalsIgnoreCase(encoder) || "refinedSoundex".equalsIgnoreCase(encoder)) {
                this.encoder = new RefinedSoundex();
            } else if ("cologne".equalsIgnoreCase(encoder)) {
                this.encoder = new ColognePhonetic();
            } else if ("double_metaphone".equalsIgnoreCase(encoder) || "doubleMetaphone".equalsIgnoreCase(encoder)) {
                DoubleMetaphone doubleMetaphone = new DoubleMetaphone();
                doubleMetaphone.setMaxCodeLen(settings.getAsInt("max_code_len", doubleMetaphone.getMaxCodeLen()));
                this.encoder = doubleMetaphone;
            } else {
                throw new ElasticSearchIllegalArgumentException("unknown encoder [" + encoder + "] for phonetic token filter");
            }
        }
    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.