0, 1, 0, 1, 0
};
@Test public void testNameFilter() throws IOException {
Reader in = new StringReader(input);
Tokenizer tok = new SentenceTokenizer(in, detector);
NameFilter nf = new NameFilter(tok, modelName, finder);
CharTermAttribute cta;
PositionIncrementAttribute pta;
OffsetAttribute oa;
int pass = 0;
while (pass < 2) { // test reuse.
int pos = 0;
int lastStart = 0;
int lastEnd = 0;
while (nf.incrementToken()) {
cta = (CharTermAttribute) nf.getAttribute(CharTermAttribute.class);
pta = (PositionIncrementAttribute) nf.getAttribute(PositionIncrementAttribute.class);
oa = (OffsetAttribute) nf.getAttribute(OffsetAttribute.class);
System.err.println("'" + cta.toString() + "'");
System.err.println(pta.toString());
System.err.println(oa.toString());
System.err.println("--- pass: " + pass);
TestCase.assertEquals(tokenStrings[pos], cta.toString());
TestCase.assertEquals(positionIncrements[pos], pta.getPositionIncrement());
if (pta.getPositionIncrement() == 0) {
TestCase.assertEquals(lastStart, oa.startOffset());
TestCase.assertEquals(lastEnd, oa.endOffset());
}
if (!cta.toString().startsWith("NE_")) {
TestCase.assertEquals(input.substring(oa.startOffset(), oa.endOffset()), cta.toString());
}
lastStart = oa.startOffset();
lastEnd = oa.endOffset();
pos++;
}
//if (pass == 1) nf.dumpState();
nf.end();
in.close();
in = new StringReader(input);
tok.reset(in);
pass++;
}
}