TermScorer explain

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

TermScorer explain

Grant Ingersoll
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: TermScorer explain

Chris Hostetter-3

: 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

I can't think of any reason why that would be a problem ... but I
approached all my work by writting a set of test cases that were as
exhaustive as i could think of, and then I only looked closely at the
explain methods that failed.  The only issue i know of with using skipTo
is spcific to NearSpan...

https://issues.apache.org/jira/browse/LUCENE-569

: change).  If I don't hear from anyone by tomorrow I will go ahead
: with it.

+1


-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]