lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Umesh Prasad <umesh.i...@gmail.com>
Subject Re: How to see results of an analyzer
Date Thu, 23 Dec 2010 07:00:11 GMT
For small texts, you can call tokenstream of Analyzer directly. That way you
don't have to crate an index.


http://lucene.apache.org/java/3_0_3/api/core/org/apache/lucene/analysis/Analyzer.html
http://lucene.apache.org/java/3_0_3/api/core/org/apache/lucene/analysis/TokenStream.html

Analyzer analyzer =  // create your analyzer.

TokenSteam ts = analyzer.tokenStream(fieldName, new
StringReader(fieldValue));

TermAttribute termAtt = ts.addAttribute(TermAttribute.class);
OffsetAttribute offsetAtt = ts.addAttribute(OffsetAttribute.class);
PositionIncrementAttribute posAtt =
ts.addAttribute(PositionIncrementAttribute.class);

while(ts.incrementToken())
{
  System.out.println(offset + "\t" + termAtt.term()  + "\t" +
posAtt.getPositionIncrement());
}


Hope that helps.



On Wed, Dec 22, 2010 at 9:28 PM, Lahiru Samarakoon <lahiruts@gmail.com>wrote:

> Hi Ian,
>
> Luke works for me.
>
> Thanks,
> Lahiru.
>



-- 
---
Thanks & Regards
Umesh Prasad

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message