Esempio n. 1
0
        /// <summary>Returns an explanation of the score for a document.
        /// <br/>When this method is used, the {@link #Next()} method
        /// and the {@link #Score(HitCollector)} method should not be used.
        /// </summary>
        /// <param name="doc">The document number for the explanation.
        /// </param>
        public override Explanation Explain(int doc)
        {
            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)
            {
                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);
        }