use of org.apache.lucene.analysis.util.ClasspathResourceLoader in project lucene-solr by apache.
the class TestStopFilterFactory method testInform.
public void testInform() throws Exception {
ResourceLoader loader = new ClasspathResourceLoader(getClass());
assertTrue("loader is null and it shouldn't be", loader != null);
StopFilterFactory factory = (StopFilterFactory) tokenFilterFactory("Stop", "words", "stop-1.txt", "ignoreCase", "true");
CharArraySet words = factory.getStopWords();
assertTrue("words is null and it shouldn't be", words != null);
assertTrue("words Size: " + words.size() + " is not: " + 2, words.size() == 2);
assertTrue(factory.isIgnoreCase() + " does not equal: " + true, factory.isIgnoreCase() == true);
factory = (StopFilterFactory) tokenFilterFactory("Stop", "words", "stop-1.txt, stop-2.txt", "ignoreCase", "true");
words = factory.getStopWords();
assertTrue("words is null and it shouldn't be", words != null);
assertTrue("words Size: " + words.size() + " is not: " + 4, words.size() == 4);
assertTrue(factory.isIgnoreCase() + " does not equal: " + true, factory.isIgnoreCase() == true);
factory = (StopFilterFactory) tokenFilterFactory("Stop", "words", "stop-snowball.txt", "format", "snowball", "ignoreCase", "true");
words = factory.getStopWords();
assertEquals(8, words.size());
assertTrue(words.contains("he"));
assertTrue(words.contains("him"));
assertTrue(words.contains("his"));
assertTrue(words.contains("himself"));
assertTrue(words.contains("she"));
assertTrue(words.contains("her"));
assertTrue(words.contains("hers"));
assertTrue(words.contains("herself"));
// defaults
factory = (StopFilterFactory) tokenFilterFactory("Stop");
assertEquals(StopAnalyzer.ENGLISH_STOP_WORDS_SET, factory.getStopWords());
assertEquals(false, factory.isIgnoreCase());
}
use of org.apache.lucene.analysis.util.ClasspathResourceLoader in project lucene-solr by apache.
the class TestPhoneticFilterFactory method testInjectFalse.
public void testInjectFalse() throws IOException {
Map<String, String> args = new HashMap<>();
args.put(PhoneticFilterFactory.ENCODER, "Metaphone");
args.put(PhoneticFilterFactory.INJECT, "false");
PhoneticFilterFactory factory = new PhoneticFilterFactory(args);
factory.inform(new ClasspathResourceLoader(factory.getClass()));
assertFalse(factory.inject);
}
use of org.apache.lucene.analysis.util.ClasspathResourceLoader in project lucene-solr by apache.
the class TestPhoneticFilterFactory method testMaxCodeLength.
public void testMaxCodeLength() throws IOException {
Map<String, String> args = new HashMap<>();
args.put(PhoneticFilterFactory.ENCODER, "Metaphone");
args.put(PhoneticFilterFactory.MAX_CODE_LENGTH, "2");
PhoneticFilterFactory factory = new PhoneticFilterFactory(args);
factory.inform(new ClasspathResourceLoader(factory.getClass()));
assertEquals(2, ((Metaphone) factory.getEncoder()).getMaxCodeLen());
}
use of org.apache.lucene.analysis.util.ClasspathResourceLoader 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);
}
use of org.apache.lucene.analysis.util.ClasspathResourceLoader in project lucene-solr by apache.
the class TestPhoneticFilterFactory method testFactoryReflectionCaverphone.
public void testFactoryReflectionCaverphone() throws IOException {
Map<String, String> args = new HashMap<>();
args.put(PhoneticFilterFactory.ENCODER, "Caverphone");
PhoneticFilterFactory factory = new PhoneticFilterFactory(args);
factory.inform(new ClasspathResourceLoader(factory.getClass()));
assertTrue(factory.getEncoder() instanceof Caverphone2);
// default
assertTrue(factory.inject);
}
Aggregations