FileDocCategorySizeDatePackage
TestSnowball.javaAPI DocApache Lucene 1.94055Mon Feb 20 09:17:46 GMT 2006org.apache.lucene.analysis.snowball

TestSnowball

public class TestSnowball extends TestCase

Fields Summary
Constructors Summary
Methods Summary
public voidassertAnalyzesTo(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 voidtestEnglish()

    Analyzer a = new SnowballAnalyzer("English");
    assertAnalyzesTo(a, "he abhorred accents",
        new String[]{"he", "abhor", "accent"});
  
public voidtestFilterTokens()

    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());