> public class CustomFilter extends TokenFilter
> {
> protected CustomFilter(TokenStream
> tokenStream)
> {
> super(tokenStream);
> }
> @Override
> public Token next(final Token reusableToken)
> throws IOException
> {
> Token nextToken =
> input.next(reusableToken);
>
> if(nextToken != null)
> {
>
> nextToken.setTermText(nextToken.termText().replaceAll(":|,|\\(|\\)|“|~|;|&|\\.",""));
> }
> return nextToken;
> }
> }
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;
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]