I searched my question in the mail archive, and found that I really want to get a phrase frequency, it is an old question which was not solved well.

I traced Lucene source code, and discover that I can get a phrase's IDF from the Hits object

weight= PhraseQuery$PhraseWeight  (id=62)
idf= 8.3973465
queryNorm= 0.11908524
queryWeight= 1.0
similarity= DefaultSimilarity  (id=66)
this$0= PhraseQuery  (id=29)
value= 8.3973465

and we can get an approximate formula: score = tf * idf

so: tf(phrase)= score / idf(phrase)


is this correct?



----- Original Message ----- From: "Daniel Noll" <[EMAIL PROTECTED]>
To: <java-user@lucene.apache.org>
Sent: Thursday, February 23, 2006 8:57 AM
Subject: Re: How can I get a term's frequency?


sog wrote:
en, but IndexReader.getTermFreqVector is an abstract method, I do not
know how to implement it in an efficient way. Anyone has good advise?

You probably don't need to implement it, it's been implemented already.
Just call the method.

I can do it in this way:

QueryTermVector vector= new QueryTermVector(Document.getValues(field));
freq = result.getTermFrequencies();

I'm not sure because I've never used QueryTermVector before, but the
fact that QueryTermVector doesn't take an IndexReader as a parameter is
a good indication that it can't tell you anything about the frequency of
the term in your documents.

Daniel




--
Daniel Noll

Nuix Australia Pty Ltd
Suite 79, 89 Jones St, Ultimo NSW 2007, Australia
Phone: (02) 9280 0699
Fax:   (02) 9212 6902

This message is intended only for the named recipient. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
message or attachment is strictly prohibited.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to