TestSnowballpublic class TestSnowball extends TestCase
Methods Summary |
---|
public void | assertAnalyzesTo(org.apache.lucene.analysis.Analyzer a, java.lang.String input, java.lang.String[] output)
TokenStream ts = a.tokenStream("dummy", new StringReader(input));
for (int i = 0; i < output.length; i++) {
Token t = ts.next();
assertNotNull(t);
assertEquals(output[i], t.termText());
}
assertNull(ts.next());
ts.close();
| public void | testEnglish()
Analyzer a = new SnowballAnalyzer("English");
assertAnalyzesTo(a, "he abhorred accents",
new String[]{"he", "abhor", "accent"});
| public void | testFilterTokens()
final Token tok = new Token("accents", 2, 7, "wrd");
tok.setPositionIncrement(3);
SnowballFilter filter = new SnowballFilter(
new TokenStream() {
public Token next() {
return tok;
}
},
"English"
);
Token newtok = filter.next();
assertEquals("accent", newtok.termText());
assertEquals(2, newtok.startOffset());
assertEquals(7, newtok.endOffset());
assertEquals("wrd", newtok.type());
assertEquals(3, newtok.getPositionIncrement());
|
|