lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Allan Casey <jaca...@deakin.edu.au>
Subject class NumberFilter extends TokenFilter
Date Sat, 01 May 2004 09:19:25 GMT
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


Mime
View raw message