EdgeNGramTokenFilterTestpublic class EdgeNGramTokenFilterTest extends TestCase Tests {@link EdgeNGramTokenFilter} for correctness. |
Fields Summary |
---|
private TokenStream | input |
Methods Summary |
---|
public void | setUp()
input = new WhitespaceTokenizer(new StringReader("abcde"));
| public void | testBackRangeOfNgrams()
EdgeNGramTokenFilter tokenizer = new EdgeNGramTokenFilter(input, EdgeNGramTokenFilter.Side.BACK, 1, 3);
Token token = null;
token = tokenizer.next();
assertEquals("(e,4,5)", token.toString());
token = tokenizer.next();
assertEquals("(de,3,5)", token.toString());
token = tokenizer.next();
assertEquals("(cde,2,5)", token.toString());
token = tokenizer.next();
assertNull(token);
| public void | testBackUnigram()
EdgeNGramTokenFilter tokenizer = new EdgeNGramTokenFilter(input, EdgeNGramTokenFilter.Side.BACK, 1, 1);
Token token = null;
token = tokenizer.next();
assertEquals("(e,4,5)", token.toString());
token = tokenizer.next();
assertNull(token);
| public void | testFrontRangeOfNgrams()
EdgeNGramTokenFilter tokenizer = new EdgeNGramTokenFilter(input, EdgeNGramTokenFilter.Side.FRONT, 1, 3);
Token token = null;
token = tokenizer.next();
assertEquals("(a,0,1)", token.toString());
token = tokenizer.next();
assertEquals("(ab,0,2)", token.toString());
token = tokenizer.next();
assertEquals("(abc,0,3)", token.toString());
token = tokenizer.next();
assertNull(token);
| public void | testFrontUnigram()
EdgeNGramTokenFilter tokenizer = new EdgeNGramTokenFilter(input, EdgeNGramTokenFilter.Side.FRONT, 1, 1);
Token token = null;
token = tokenizer.next();
assertEquals("(a,0,1)", token.toString());
token = tokenizer.next();
assertNull(token);
| public void | testInvalidInput()
boolean gotException = false;
try {
new EdgeNGramTokenFilter(input, EdgeNGramTokenFilter.Side.FRONT, 0, 0);
} catch (IllegalArgumentException e) {
gotException = true;
}
assertTrue(gotException);
| public void | testInvalidInput2()
boolean gotException = false;
try {
new EdgeNGramTokenFilter(input, EdgeNGramTokenFilter.Side.FRONT, 2, 1);
} catch (IllegalArgumentException e) {
gotException = true;
}
assertTrue(gotException);
| public void | testInvalidInput3()
boolean gotException = false;
try {
new EdgeNGramTokenFilter(input, EdgeNGramTokenFilter.Side.FRONT, -1, 2);
} catch (IllegalArgumentException e) {
gotException = true;
}
assertTrue(gotException);
| public void | testOversizedNgrams()
EdgeNGramTokenFilter tokenizer = new EdgeNGramTokenFilter(input, EdgeNGramTokenFilter.Side.FRONT, 6, 6);
Token token = null;
token = tokenizer.next();
assertNull(token);
|
|