lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas arni <>
Subject Re: TF-IDF API
Date Wed, 28 Mar 2007 09:18:23 GMT
Hava a look at the "TermDocs" Interface in the API.

You can get term frequency  with a open IndexReader

TermDocs termDocs = reader.termDocs(term);

where "term" represents the current Term.

now you can call:


to get the frequency of the term within the current document.

For the calculation of the idf, you can use the provided formula from 
the "DefaultSimilarity".
To get the document frequency, which is necessary to calculate the idf, 
you can call:


Hope this helps...


Sengly Heng wrote:
> Hello Luceners,
> I have a collections of vector of terms (token) that I extracted from 
> files.
> I am looking for ways to calculate TF/IDF of each term.
> I wanted to use Lucene to do this but Lucene is made for collections of
> files and in my case I have already extracted those files into vector of
> terms. I know it is not very difficult to implement this measurement 
> but I
> guess there should be such API available. Does anyone of you know any 
> Java
> API that directly handle this problem? or I have to implement from 
> scratch.
> Any idea would be highly appreciated.
> Thank you in advance.
> Best regards,
> Sengly

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message