Hi, I find it is very hard to implement a GivenCharFilter(extends TokenFilter)using incrementToken. My requirment is like this: I want to analyze a StringReader("axb xxa xx c") to these token[term(startOffset, endOffset, posIncre)]: a(0,1,1) b(2,3,1) a(4,5,1) c(6,7,1). First I use a WhiteSpaceFilter to filter the token, and then use GivenCharFilter( assume filter "x" like above). the problem is: when call incrementToken, I get attributeTerm "axb", but this time I need return two attribute terms "a" and "b", but how to? because it just return only one term. Please help me.
My code just like this: ============================================ public class GivenCharFilter extends TokenFilter{ private char filterChar='x'; private TermAttribute termAtt; private OffsetAttribute offsetAtt; private PositionIncrementAttribute posIncrAtt; public GivenCharFilter(){ init(); } public void init() { termAtt = (TermAttribute) addAttribute(TermAttribute.class); offsetAtt = (OffsetAttribute) addAttribute(OffsetAttribute.class); posIncrAtt = (PositionIncrementAttribute) addAttribute(PositionIncrementAttribute.class); } /** Returns the next token in the stream, or null at EOS. */ public final boolean incrementToken() throws IOException { //How To? } } ================================ Regards, Xiaotao Deng -- View this message in context: http://old.nabble.com/How-to-implement-a-GivenCharFilter-using-incrementToken-tp26507318p26507318.html Sent from the Lucene - Java Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org