lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Calabrese <m...@jasoncalabrese.com>
Subject Re: Stemming terms in SpanQuery
Date Wed, 03 May 2006 01:29:40 GMT
I think the best way to tokening/stem is to use the analyzer directly.  for 
example:

TokenStream ts = analyzer.tokenStream(field, new StringReader(text));
				
Token token = null;
while ((token = ts.next()) != null) {
	Term newTerm = new Term(field, token.termText());
	//do something with the new newTerm
}

If your just stemming then there will be only a single token so you probably 
won't need the while loop.

On Monday 01 May 2006 12:37, Michael Chan wrote:
> Hi,
>
> I'm trying to build a SpanQuery using word stems. Is parsing each term
> with a QueryParser, constructed with an Analyzer giving stemmed
> tokenStream, the right approach? It just seems to me that QueryParser is
> designed to parse queries, and so my hunch is that there might be a
> better way.
>
> Any help will be much appreciated.
>
> Michael
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org

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


Mime
View raw message