lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grant Ingersoll <gsing...@syr.edu>
Subject Re: Num of a term in a Doc
Date Fri, 02 Jun 2006 13:13:22 GMT
You can do this a couple of different ways (at least):
1. Use term vectors.  See http://www.cnlp.org/apachecon2005 for an 
intro, search on this list, or look in Erik and Otis book Lucene In 
Action.  This will be the fastest way, but will require more space in 
your index to store the term vectors.

2. Iterate over the TermDocs interface.  See IndexReader.termDocs() 
method for how to get an instance.


Mary S wrote:
> Hi,
>
> I want to get the freq of a term in a Doc.
>
> public int termFreq( int docID, String termName ) {
>
>   IndexReader reader = IndexReader.open(directory);
>   Document doc = reader.document(docID);
>
>   int FreqForTerm = doc.... ???
>   return FreqForTerm;
> }
>
>
> I didn't find what I want in the archives.
>
> Can someone please assist?
>
>
> Mary
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

-- 

Grant Ingersoll 
Sr. Software Engineer 
Center for Natural Language Processing 
Syracuse University 
School of Information Studies 
335 Hinds Hall 
Syracuse, NY 13244 

http://www.cnlp.org 
Voice:  315-443-5484 
Fax: 315-443-6886 


---------------------------------------------------------------------
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