use of org.apache.lucene.analysis.util.StringMockResourceLoader in project lucene-solr by apache.
the class TestSynonymFilterFactory method testEmptySynonyms.
/** if the synonyms are completely empty, test that we still analyze correctly */
public void testEmptySynonyms() throws Exception {
Reader reader = new StringReader("GB");
TokenStream stream = whitespaceMockTokenizer(reader);
stream = tokenFilterFactory("Synonym", Version.LATEST, // empty file!
new StringMockResourceLoader(""), "synonyms", "synonyms.txt").create(stream);
assertTokenStreamContents(stream, new String[] { "GB" });
}
use of org.apache.lucene.analysis.util.StringMockResourceLoader in project lucene-solr by apache.
the class TestKeywordMarkerFilterFactory method testKeywordsMixed.
public void testKeywordsMixed() throws Exception {
Reader reader = new StringReader("dogs cats birds");
TokenStream stream = whitespaceMockTokenizer(reader);
stream = tokenFilterFactory("KeywordMarker", Version.LATEST, new StringMockResourceLoader("cats"), "protected", "protwords.txt", "pattern", "birds|Dogs").create(stream);
stream = tokenFilterFactory("PorterStem").create(stream);
assertTokenStreamContents(stream, new String[] { "dog", "cats", "birds" });
}
use of org.apache.lucene.analysis.util.StringMockResourceLoader in project lucene-solr by apache.
the class TestKeywordMarkerFilterFactory method testKeywords.
public void testKeywords() throws Exception {
Reader reader = new StringReader("dogs cats");
TokenStream stream = whitespaceMockTokenizer(reader);
stream = tokenFilterFactory("KeywordMarker", Version.LATEST, new StringMockResourceLoader("cats"), "protected", "protwords.txt").create(stream);
stream = tokenFilterFactory("PorterStem").create(stream);
assertTokenStreamContents(stream, new String[] { "dog", "cats" });
}
use of org.apache.lucene.analysis.util.StringMockResourceLoader in project lucene-solr by apache.
the class TestKeywordMarkerFilterFactory method testKeywordsCaseInsensitiveMixed.
public void testKeywordsCaseInsensitiveMixed() throws Exception {
Reader reader = new StringReader("dogs cats Cats Birds birds");
TokenStream stream = whitespaceMockTokenizer(reader);
stream = tokenFilterFactory("KeywordMarker", Version.LATEST, new StringMockResourceLoader("cats"), "protected", "protwords.txt", "pattern", "birds", "ignoreCase", "true").create(stream);
stream = tokenFilterFactory("PorterStem").create(stream);
assertTokenStreamContents(stream, new String[] { "dog", "cats", "Cats", "Birds", "birds" });
}
use of org.apache.lucene.analysis.util.StringMockResourceLoader in project lucene-solr by apache.
the class TestStemmerOverrideFilterFactory method testKeywords.
public void testKeywords() throws Exception {
// our stemdict stems dogs to 'cat'
Reader reader = new StringReader("testing dogs");
TokenStream stream = whitespaceMockTokenizer(reader);
stream = tokenFilterFactory("StemmerOverride", Version.LATEST, new StringMockResourceLoader("dogs\tcat"), "dictionary", "stemdict.txt").create(stream);
stream = tokenFilterFactory("PorterStem").create(stream);
assertTokenStreamContents(stream, new String[] { "test", "cat" });
}
Aggregations