Hi, > Here is the the one that uses new token stream api: > > public final class CustomFilter extends TokenFilter { > > private final TermAttribute termAtt; > > public CustomFilter(TokenStream in, FastZemberek zemberek) { > super(in); > termAtt = (TermAttribute) addAttribute(TermAttribute.class); > } > > public final boolean incrementToken() throws IOException { > if (input.incrementToken()) { > String term = termAtt.term(); > String s = term.replaceAll(":|,|\\(|\\)|"|~|;|&|\\.",""); > if (s != null && !s.equals(term)) > termAtt.setTermBuffer(s); > return true; > } else { > return false; > } > } > } >
As a note: As you are using Lucene 3.0 with Java 5, the casts of addAttribute() can be removed, they were only be needed for Java 1.4 compatibility in Lucene 2.9! 3.0 uses generics, so the line in the ctor is in Lucene 3.0: termAtt = addAttribute(TermAttribute.class); And it can even be shorter without the ctor at all, just use: private final TermAttribute termAtt = addAttribute(TermAttribute.class); (in the declaration and remove the ctor). Happy Xmas, Uwe --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org