lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grant Ingersoll <gsing...@syr.edu>
Subject TermScorer explain
Date Fri, 18 Aug 2006 15:35:52 GMT
Anyone see any reason why I shouldn't make the following commit to  
TermScorer explain per Otis' TODO comment on the method:     * @todo  
Modify to make use of {@link TermDocs#skipTo(int)}.

   public Explanation explain(int doc) throws IOException {
     TermQuery query = (TermQuery)weight.getQuery();
     Explanation tfExplanation = new Explanation();
     int tf = 0;
     while (pointer < pointerMax) {
       if (docs[pointer] == doc)
         tf = freqs[pointer];
       pointer++;
     }
     if (tf == 0) {
//----- CHANGE IS HERE
         if (termDocs.skipTo(doc))
         {
             if (termDocs.doc() == doc)
             {
                 tf = termDocs.freq();
             }
         }
     }
     termDocs.close();
     tfExplanation.setValue(getSimilarity().tf(tf));
     tfExplanation.setDescription("tf(termFreq("+query.getTerm()+") 
="+tf+")");

     return tfExplanation;
   }

I have also implemented TestTermScorer and will be committing that  
soon too.  Just came across this while writing up documentation on  
scoring and thought it sounded like a reasonable and easy fix.  I  
know Hoss has done a lot with Explanations, so he may know best if  
there are issues with skipTo and explain.  All tests still pass  
(including the new one for TermScorer (which also passed b4 the  
change).  If I don't hear from anyone by tomorrow I will go ahead  
with it.

Thanks,
-Grant



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


Mime
View raw message