Package org.apache.commons.codec.language

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

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

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


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

  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

      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

TOP

Related Classes of org.apache.commons.codec.language.DoubleMetaphone

Copyright © 2018 www.massapicom. 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.