EdgeNGramTokenizerTestpublic class EdgeNGramTokenizerTest extends TestCase Tests {@link EdgeNGramTokenizer} for correctness. |
Fields Summary |
---|
private StringReader | input |
Methods Summary |
---|
public void | setUp()
input = new StringReader("abcde");
| public void | testBackRangeOfNgrams()
EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, EdgeNGramTokenizer.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()
EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, EdgeNGramTokenizer.Side.BACK, 1, 1);
Token token = null;
token = tokenizer.next();
assertEquals("(e,4,5)", token.toString());
token = tokenizer.next();
assertNull(token);
| public void | testFrontRangeOfNgrams()
EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, EdgeNGramTokenizer.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()
EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, EdgeNGramTokenizer.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 EdgeNGramTokenizer(input, EdgeNGramTokenizer.Side.FRONT, 0, 0);
} catch (IllegalArgumentException e) {
gotException = true;
}
assertTrue(gotException);
| public void | testInvalidInput2()
boolean gotException = false;
try {
new EdgeNGramTokenizer(input, EdgeNGramTokenizer.Side.FRONT, 2, 1);
} catch (IllegalArgumentException e) {
gotException = true;
}
assertTrue(gotException);
| public void | testInvalidInput3()
boolean gotException = false;
try {
new EdgeNGramTokenizer(input, EdgeNGramTokenizer.Side.FRONT, -1, 2);
} catch (IllegalArgumentException e) {
gotException = true;
}
assertTrue(gotException);
| public void | testOversizedNgrams()
EdgeNGramTokenizer tokenizer = new EdgeNGramTokenizer(input, EdgeNGramTokenizer.Side.FRONT, 6, 6);
Token token = null;
token = tokenizer.next();
assertNull(token);
|
|