use of org.apache.lucene.analysis.Analyzer in project lucene-solr by apache.
the class TestSynonymGraphFilter method getFlattenAnalyzer.
/** Appends FlattenGraphFilter too */
private Analyzer getFlattenAnalyzer(SynonymMap.Builder b, boolean ignoreCase) throws IOException {
final SynonymMap map = b.build();
return new Analyzer() {
@Override
protected TokenStreamComponents createComponents(String fieldName) {
Tokenizer tokenizer = new MockTokenizer(MockTokenizer.WHITESPACE, true);
// Make a local variable so testRandomHuge doesn't share it across threads!
SynonymGraphFilter synFilter = new SynonymGraphFilter(tokenizer, map, ignoreCase);
FlattenGraphFilter flattenFilter = new FlattenGraphFilter(synFilter);
TestSynonymGraphFilter.this.synFilter = synFilter;
TestSynonymGraphFilter.this.flattenFilter = flattenFilter;
return new TokenStreamComponents(tokenizer, flattenFilter);
}
};
}
use of org.apache.lucene.analysis.Analyzer in project lucene-solr by apache.
the class TestSynonymGraphFilter method testBufferedFinish1.
public void testBufferedFinish1() throws Exception {
SynonymMap.Builder b = new SynonymMap.Builder();
add(b, "a b c", "m n o", false);
Analyzer a = getAnalyzer(b, true);
assertAnalyzesTo(a, "c a b", new String[] { "c", "a", "b" }, new int[] { 0, 2, 4 }, new int[] { 1, 3, 5 }, new String[] { "word", "word", "word" }, new int[] { 1, 1, 1 }, new int[] { 1, 1, 1 });
a.close();
}
use of org.apache.lucene.analysis.Analyzer in project lucene-solr by apache.
the class TestSynonymGraphFilter method testSynAtEnd.
public void testSynAtEnd() throws Exception {
SynonymMap.Builder b = new SynonymMap.Builder();
add(b, "a b", "x", true);
Analyzer a = getAnalyzer(b, true);
assertAnalyzesTo(a, "c d e a b", new String[] { "c", "d", "e", "x", "a", "b" }, new int[] { 0, 2, 4, 6, 6, 8 }, new int[] { 1, 3, 5, 9, 7, 9 }, new String[] { "word", "word", "word", "SYNONYM", "word", "word" }, new int[] { 1, 1, 1, 1, 0, 1 }, new int[] { 1, 1, 1, 2, 1, 1 });
a.close();
}
use of org.apache.lucene.analysis.Analyzer in project lucene-solr by apache.
the class TestSynonymGraphFilter method testDoNotIgnoreCase.
public void testDoNotIgnoreCase() throws Exception {
SynonymMap.Builder b = new SynonymMap.Builder();
add(b, "a b", "x y", false);
add(b, "a b", "m n o", false);
Analyzer a = getAnalyzer(b, false);
assertAnalyzesTo(a, "c A B D", new String[] { "c", "A", "B", "D" }, new int[] { 0, 2, 4, 6 }, new int[] { 1, 3, 5, 7 }, new String[] { "word", "word", "word", "word" }, new int[] { 1, 1, 1, 1 }, new int[] { 1, 1, 1, 1 });
a.close();
}
use of org.apache.lucene.analysis.Analyzer in project lucene-solr by apache.
the class TestSynonymGraphFilter method testBasicNoKeepOrigTwoOutputs.
public void testBasicNoKeepOrigTwoOutputs() throws Exception {
SynonymMap.Builder b = new SynonymMap.Builder();
add(b, "a b", "x y", false);
add(b, "a b", "m n o", false);
Analyzer a = getAnalyzer(b, true);
assertAnalyzesTo(a, "c a b d", new String[] { "c", "x", "m", "y", "n", "o", "d" }, new int[] { 0, 2, 2, 2, 2, 2, 6 }, new int[] { 1, 5, 5, 5, 5, 5, 7 }, new String[] { "word", "SYNONYM", "SYNONYM", "SYNONYM", "SYNONYM", "SYNONYM", "word" }, new int[] { 1, 1, 0, 1, 1, 1, 1 }, new int[] { 1, 1, 2, 3, 1, 1, 1 });
a.close();
}
Aggregations