Search in sources :

Example 6 with Metaphone

use of org.apache.commons.codec.language.Metaphone in project lucene-solr by apache.

the class TestPhoneticFilter method testEmptyTerm.

public void testEmptyTerm() throws IOException {
    Encoder[] encoders = new Encoder[] { new Metaphone(), new DoubleMetaphone(), new Soundex(), new RefinedSoundex(), new Caverphone2() };
    for (final Encoder e : encoders) {
        Analyzer a = new Analyzer() {

            @Override
            protected TokenStreamComponents createComponents(String fieldName) {
                Tokenizer tokenizer = new KeywordTokenizer();
                return new TokenStreamComponents(tokenizer, new PhoneticFilter(tokenizer, e, random().nextBoolean()));
            }
        };
        checkOneTerm(a, "", "");
        a.close();
    }
}
Also used : RefinedSoundex(org.apache.commons.codec.language.RefinedSoundex) DoubleMetaphone(org.apache.commons.codec.language.DoubleMetaphone) Metaphone(org.apache.commons.codec.language.Metaphone) Caverphone2(org.apache.commons.codec.language.Caverphone2) Analyzer(org.apache.lucene.analysis.Analyzer) KeywordTokenizer(org.apache.lucene.analysis.core.KeywordTokenizer) RefinedSoundex(org.apache.commons.codec.language.RefinedSoundex) Soundex(org.apache.commons.codec.language.Soundex) DoubleMetaphone(org.apache.commons.codec.language.DoubleMetaphone) Encoder(org.apache.commons.codec.Encoder) Tokenizer(org.apache.lucene.analysis.Tokenizer) MockTokenizer(org.apache.lucene.analysis.MockTokenizer) KeywordTokenizer(org.apache.lucene.analysis.core.KeywordTokenizer)

Example 7 with Metaphone

use of org.apache.commons.codec.language.Metaphone in project lucene-solr by apache.

the class TestPhoneticFilterFactory method testFactoryReflection.

/**
   * Case: Reflection
   */
public void testFactoryReflection() throws IOException {
    Map<String, String> args = new HashMap<>();
    args.put(PhoneticFilterFactory.ENCODER, "org.apache.commons.codec.language.Metaphone");
    PhoneticFilterFactory factory = new PhoneticFilterFactory(args);
    factory.inform(new ClasspathResourceLoader(factory.getClass()));
    assertTrue(factory.getEncoder() instanceof Metaphone);
    // default
    assertTrue(factory.inject);
}
Also used : HashMap(java.util.HashMap) Metaphone(org.apache.commons.codec.language.Metaphone) ClasspathResourceLoader(org.apache.lucene.analysis.util.ClasspathResourceLoader)

Aggregations

Metaphone (org.apache.commons.codec.language.Metaphone)7 Caverphone2 (org.apache.commons.codec.language.Caverphone2)3 DoubleMetaphone (org.apache.commons.codec.language.DoubleMetaphone)3 RefinedSoundex (org.apache.commons.codec.language.RefinedSoundex)3 Soundex (org.apache.commons.codec.language.Soundex)3 JaroWinklerDistance (ai.saiy.android.algorithms.distance.jarowinkler.JaroWinklerDistance)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Encoder (org.apache.commons.codec.Encoder)2 Analyzer (org.apache.lucene.analysis.Analyzer)2 MockTokenizer (org.apache.lucene.analysis.MockTokenizer)2 Tokenizer (org.apache.lucene.analysis.Tokenizer)2 KeywordTokenizer (org.apache.lucene.analysis.core.KeywordTokenizer)2 ClasspathResourceLoader (org.apache.lucene.analysis.util.ClasspathResourceLoader)2 CustomCommand (ai.saiy.android.custom.CustomCommand)1 CustomCommandContainer (ai.saiy.android.custom.CustomCommandContainer)1 AlgorithmicContainer (ai.saiy.android.nlu.local.AlgorithmicContainer)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 Nysiis (org.apache.commons.codec.language.Nysiis)1