SOLR-1923: add caverphone to phoneticfilter

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@948011 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-05-25 11:53:55 +00:00
parent f237405809
commit 7baa7b17ac
3 changed files with 11 additions and 0 deletions

View File

@ -161,6 +161,9 @@ New Features
* SOLR-945: JSON update handler that accepts add, delete, commit
commands in JSON format. (Ryan McKinley, yonik)
* SOLR-1923: PhoneticFilterFactory now has support for the
Caverphone algorithm. (rmuir)
Optimizations
----------------------

View File

@ -23,6 +23,7 @@ import java.util.Locale;
import java.util.Map;
import org.apache.commons.codec.Encoder;
import org.apache.commons.codec.language.Caverphone;
import org.apache.commons.codec.language.DoubleMetaphone;
import org.apache.commons.codec.language.Metaphone;
import org.apache.commons.codec.language.RefinedSoundex;
@ -56,6 +57,7 @@ public class PhoneticFilterFactory extends BaseTokenFilterFactory
registry.put( "Metaphone".toUpperCase(Locale.ENGLISH), Metaphone.class );
registry.put( "Soundex".toUpperCase(Locale.ENGLISH), Soundex.class );
registry.put( "RefinedSoundex".toUpperCase(Locale.ENGLISH), RefinedSoundex.class );
registry.put( "Caverphone".toUpperCase(Locale.ENGLISH), Caverphone.class );
}
protected boolean inject = true;

View File

@ -79,6 +79,12 @@ public class TestPhoneticFilter extends BaseTokenTestCase {
new String[] { "A0", "aaa", "B1", "bbb", "C3", "ccc", "E034034", "easgasg" });
assertAlgorithm("RefinedSoundex", "false", "aaa bbb ccc easgasg",
new String[] { "A0", "B1", "C3", "E034034" });
assertAlgorithm("Caverphone", "true", "Darda Karleen Datha Carlene",
new String[] { "TTA1111111", "Darda", "KLN1111111", "Karleen",
"TTA1111111", "Datha", "KLN1111111", "Carlene" });
assertAlgorithm("Caverphone", "false", "Darda Karleen Datha Carlene",
new String[] { "TTA1111111", "KLN1111111", "TTA1111111", "KLN1111111" });
}
static void assertAlgorithm(String algName, String inject, String input,