You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by John Allan Casey <ja...@deakin.edu.au> on 2004/05/01 11:19:25 UTC

class NumberFilter extends TokenFilter

Recently I wrote a small NumberFilter similar in structure to the
StopFilter except it filters out numeric tokens.  Anyway, here is the
simple source code if you are interested in adding it into the API as it
would seem to be something that needs to be done fairly often ???

class NumberFilter extends TokenFilter
{
	NumberFilter(TokenStream in)
	{
		super(in);
	}
	public Token next() throws IOException
	{
		for(Token token = input.next(); token != null; token = input.next())
		{
			if(Character.isDigit(token.termText().charAt(0))==false)
				return token;
		}
		return null;
	}
}

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org