Ejemplo n.º 1
0
        /// <returns> An explanation for the score of a given document.
        /// </returns>
        public override Explanation Explain(int doc)
        {
            Explanation res = new Explanation();

            System.Collections.IEnumerator ssi = subScorers.GetEnumerator();
            float sumScore  = 0.0f;
            int   nrMatches = 0;

            while (ssi.MoveNext())
            {
                Explanation es = ((Scorer)ssi.Current).Explain(doc);
                if (es.GetValue() > 0.0f)
                {
                    // indicates match
                    sumScore += es.GetValue();
                    nrMatches++;
                }
                res.AddDetail(es);
            }
            if (nrMatchers >= minimumNrMatchers)
            {
                res.SetValue(sumScore);
                res.SetDescription("sum over at least " + minimumNrMatchers + " of " + subScorers.Count + ":");
            }
            else
            {
                res.SetValue(0.0f);
                res.SetDescription(nrMatches + " match(es) but at least " + minimumNrMatchers + " of " + subScorers.Count + " needed");
            }
            return(res);
        }
Ejemplo n.º 2
0
        /// <returns> An explanation for the score of a given document.
        /// </returns>
        public override Explanation Explain(int doc)
        {
            Explanation res       = new Explanation();
            float       sumScore  = 0.0f;
            int         nrMatches = 0;

            foreach (Scorer s in subScorers)
            {
                Explanation es = s.Explain(doc);
                if (es.GetValue() > 0.0f)
                {
                    // indicates match
                    sumScore += es.GetValue();
                    nrMatches++;
                }
                res.AddDetail(es);
            }
            if (nrMatchers >= minimumNrMatchers)
            {
                res.SetValue(sumScore);
                res.SetDescription("sum over at least " + minimumNrMatchers + " of " + subScorers.Count + ":");
            }
            else
            {
                res.SetValue(0.0f);
                res.SetDescription(nrMatches + " match(es) but at least " + minimumNrMatchers + " of " + subScorers.Count + " needed");
            }
            return(res);
        }
Ejemplo n.º 3
0
                // add an explanation about whether the document was filtered
                public override Explanation Explain(int i)
                {
                    Explanation exp = scorer.Explain(i);

                    if (bitset.Get(i))
                    {
                        exp.SetDescription("allowed by filter: " + exp.GetDescription());
                    }
                    else
                    {
                        exp.SetDescription("removed by filter: " + exp.GetDescription());
                    }
                    return(exp);
                }
 public override Explanation Explain(int doc)
 {
     Explanation res = new Explanation();
     if (exclScorer.SkipTo(doc) && (exclScorer.Doc() == doc))
     {
         res.SetDescription("excluded");
     }
     else
     {
         res.SetDescription("not excluded");
         res.AddDetail(reqScorer.Explain(doc));
     }
     return res;
 }
Ejemplo n.º 5
0
        public override Explanation Explain(int doc)
        {
            Explanation res = new Explanation();

            if (exclScorer.SkipTo(doc) && (exclScorer.Doc() == doc))
            {
                res.SetDescription("excluded");
            }
            else
            {
                res.SetDescription("not excluded");
                res.AddDetail(reqScorer.Explain(doc));
            }
            return(res);
        }
Ejemplo n.º 6
0
        public override Explanation Explain(int doc)
        {
            Explanation res = new Explanation();

            if (exclDisi.Advance(doc) == doc)
            {
                res.SetDescription("excluded");
            }
            else
            {
                res.SetDescription("not excluded");
                res.AddDetail(reqScorer.Explain(doc));
            }
            return(res);
        }
Ejemplo n.º 7
0
			public override Explanation Explain(int doc)
			{
				Explanation explanation = new Explanation();
				explanation.SetValue(1.0f);
				explanation.SetDescription("MatchAllDocsQuery");
				return explanation;
			}
Ejemplo n.º 8
0
                // add an explanation about whether the document was filtered
                public override Explanation Explain(int i)
                {
                    Explanation exp = scorer.Explain(i);

                    if (docIdSetIterator.Advance(i) == i)
                    {
                        exp.SetDescription("allowed by filter: " + exp.GetDescription());
                        exp.SetValue(Enclosing_Instance.Enclosing_Instance.GetBoost() * exp.GetValue());
                    }
                    else
                    {
                        exp.SetDescription("removed by filter: " + exp.GetDescription());
                        exp.SetValue(0.0f);
                    }
                    return(exp);
                }
Ejemplo n.º 9
0
                // add an explanation about whether the document was filtered
                public override Explanation Explain(int i)
                {
                    Explanation exp = scorer.Explain(i);

                    exp.SetValue(Enclosing_Instance.Enclosing_Instance.GetBoost() * exp.GetValue());

                    if (bitset.Get(i))
                    {
                        exp.SetDescription("allowed by filter: " + exp.GetDescription());
                    }
                    else
                    {
                        exp.SetDescription("removed by filter: " + exp.GetDescription());
                    }
                    return(exp);
                }
Ejemplo n.º 10
0
        public override Explanation Explain(int doc)
        {
            Explanation e = new Explanation();

            e.SetDescription("No document matches.");
            return(e);
        }
Ejemplo n.º 11
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>
        /// <todo>  Modify to make use of {@link TermDocs#SkipTo(int)}. </todo>
        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)
            {
                while (termDocs.Next())
                {
                    if (termDocs.Doc() == doc)
                    {
                        tf = termDocs.Freq();
                    }
                }
            }
            termDocs.Close();
            tfExplanation.SetValue(GetSimilarity().Tf(tf));
            tfExplanation.SetDescription("tf(termFreq(" + query.GetTerm() + ")=" + tf + ")");

            return(tfExplanation);
        }
 /// <summary>Explain the score of a document.</summary>
 /// <todo>  Also show the total score. </todo>
 /// <summary> See BooleanScorer.explain() on how to do this.
 /// </summary>
 public override Explanation Explain(int doc)
 {
     Explanation res = new Explanation();
     res.SetDescription("required, optional");
     res.AddDetail(reqScorer.Explain(doc));
     res.AddDetail(optScorer.Explain(doc));
     return res;
 }
Ejemplo n.º 13
0
            public override Explanation Explain(int doc)
            {
                Explanation explanation = new Explanation();

                explanation.SetValue(1.0f);
                explanation.SetDescription("MatchAllDocsQuery");
                return(explanation);
            }
Ejemplo n.º 14
0
        /// <summary>Explain the score of a document.</summary>
        /// <todo>  Also show the total score. </todo>
        /// <summary> See BooleanScorer.explain() on how to do this.
        /// </summary>
        public override Explanation Explain(int doc)
        {
            Explanation res = new Explanation();

            res.SetDescription("required, optional");
            res.AddDetail(reqScorer.Explain(doc));
            res.AddDetail(optScorer.Explain(doc));
            return(res);
        }
Ejemplo n.º 15
0
        public override Explanation Explain(IndexReader reader, int doc)
        {
            ComplexExplanation result = new ComplexExplanation();
            result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");
            System.String field = ((SpanQuery) GetQuery()).GetField();

            Explanation idfExpl = new Explanation(idf, "idf(" + field + ": " + idfExp.Explain() + ")");

            // explain query weight
            Explanation queryExpl = new Explanation();
            queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");

            Explanation boostExpl = new Explanation(GetQuery().GetBoost(), "boost");
            if (GetQuery().GetBoost() != 1.0f)
                queryExpl.AddDetail(boostExpl);
            queryExpl.AddDetail(idfExpl);

            Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
            queryExpl.AddDetail(queryNormExpl);

            queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());

            result.AddDetail(queryExpl);

            // explain field weight
            ComplexExplanation fieldExpl = new ComplexExplanation();
            fieldExpl.SetDescription("fieldWeight(" + field + ":" + query.ToString(field) + " in " + doc + "), product of:");

            Explanation tfExpl = Scorer(reader, true, false).Explain(doc);
            fieldExpl.AddDetail(tfExpl);
            fieldExpl.AddDetail(idfExpl);

            Explanation fieldNormExpl = new Explanation();
            byte[] fieldNorms = reader.Norms(field);
            float fieldNorm = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]):1.0f;
            fieldNormExpl.SetValue(fieldNorm);
            fieldNormExpl.SetDescription("fieldNorm(field=" + field + ", doc=" + doc + ")");
            fieldExpl.AddDetail(fieldNormExpl);

            fieldExpl.SetMatch(tfExpl.IsMatch());
            fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());

            result.AddDetail(fieldExpl);
            System.Boolean tempAux = fieldExpl.GetMatch();
            result.SetMatch(tempAux);

            // combine them
            result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());

            if (queryExpl.GetValue() == 1.0f)
                return fieldExpl;

            return result;
        }
Ejemplo n.º 16
0
        /// <summary>Gives and explanation for the score of a given document.</summary>
        /// <todo>  Show the resulting score. See BooleanScorer.explain() on how to do this. </todo>
        public override Explanation Explain(int doc)
        {
            Explanation res = new Explanation();

            res.SetDescription("At least " + minimumNrMatchers + " of");
            System.Collections.IEnumerator ssi = subScorers.GetEnumerator();
            while (ssi.MoveNext())
            {
                res.AddDetail(((Scorer)ssi.Current).Explain(doc));
            }
            return(res);
        }
Ejemplo n.º 17
0
        public override Explanation Explain(int doc)
        {
            Explanation tfExplanation = new Explanation();

            int   d          = Advance(doc);
            float phraseFreq = (d == doc)?freq:0.0f;

            tfExplanation.SetValue(GetSimilarity().Tf(phraseFreq));
            tfExplanation.SetDescription("tf(phraseFreq=" + phraseFreq + ")");

            return(tfExplanation);
        }
Ejemplo n.º 18
0
            public virtual Explanation Explain(IndexReader reader, int doc)
            {
                ConstantScorer cs     = (ConstantScorer)Scorer(reader);
                bool           exists = cs.bits.Get(doc);

                Explanation result = new Explanation();

                if (exists)
                {
                    result.SetDescription("ConstantScoreQuery(" + Enclosing_Instance.filter + "), product of:");
                    result.SetValue(queryWeight);
                    result.AddDetail(new Explanation(Enclosing_Instance.GetBoost(), "boost"));
                    result.AddDetail(new Explanation(queryNorm, "queryNorm"));
                }
                else
                {
                    result.SetDescription("ConstantScoreQuery(" + Enclosing_Instance.filter + ") doesn't match id " + doc);
                    result.SetValue(0);
                }
                return(result);
            }
Ejemplo n.º 19
0
            public virtual Explanation Explain(IndexReader reader, int doc)
            {
                // explain query weight
                Explanation queryExpl = new Explanation();

                queryExpl.SetDescription("MatchAllDocsQuery, product of:");
                queryExpl.SetValue(GetValue());
                if (Enclosing_Instance.GetBoost() != 1.0f)
                {
                    queryExpl.AddDetail(new Explanation(Enclosing_Instance.GetBoost(), "boost"));
                }
                queryExpl.AddDetail(new Explanation(queryNorm, "queryNorm"));

                return(queryExpl);
            }
Ejemplo n.º 20
0
        public override Explanation Explain(int doc)
        {
            Explanation tfExplanation = new Explanation();

            while (Next() && Doc() < doc)
            {
            }

            float phraseFreq = (Doc() == doc)?freq:0.0f;

            tfExplanation.SetValue(GetSimilarity().Tf(phraseFreq));
            tfExplanation.SetDescription("tf(phraseFreq=" + phraseFreq + ")");

            return(tfExplanation);
        }
Ejemplo n.º 21
0
                public override Explanation CustomExplain(int doc, Explanation subQueryExpl, Explanation[] valSrcExpls)
                {
                    if (valSrcExpls.Length == 0)
                    {
                        return(subQueryExpl);
                    }
                    Explanation exp = new Explanation(valSrcExpls[0].GetValue() + subQueryExpl.GetValue(), "sum of:");

                    exp.AddDetail(subQueryExpl);
                    exp.AddDetail(valSrcExpls[0]);
                    if (valSrcExpls.Length == 1)
                    {
                        exp.SetDescription("CustomMulAdd, sum of:");
                        return(exp);
                    }
                    Explanation exp2 = new Explanation(valSrcExpls[1].GetValue() * exp.GetValue(), "custom score: product of:");

                    exp2.AddDetail(valSrcExpls[1]);
                    exp2.AddDetail(exp);
                    return(exp2);
                }
Ejemplo n.º 22
0
            /* Explain the score we computed for doc */
            public virtual Explanation Explain(IndexReader reader, int doc)
            {
                if (Enclosing_Instance.disjuncts.Count == 1)
                {
                    return(((Weight)weights[0]).Explain(reader, doc));
                }
                Explanation result = new Explanation();
                float       max = 0.0f, sum = 0.0f;

                result.SetDescription(Enclosing_Instance.tieBreakerMultiplier == 0.0f ? "max of:" : "max plus " + Enclosing_Instance.tieBreakerMultiplier + " times others of:");
                for (int i = 0; i < weights.Count; i++)
                {
                    Explanation e = ((Weight)weights[i]).Explain(reader, doc);
                    if (e.GetValue() > 0)
                    {
                        result.AddDetail(e);
                        sum += e.GetValue();
                        max  = System.Math.Max(max, e.GetValue());
                    }
                }
                result.SetValue(max + (sum - max) * Enclosing_Instance.tieBreakerMultiplier);
                return(result);
            }
Ejemplo n.º 23
0
		/// <summary>Gives and explanation for the score of a given document.</summary>
		/// <todo>  Show the resulting score. See BooleanScorer.explain() on how to do this. </todo>
		public override Explanation Explain(int doc)
		{
			Explanation res = new Explanation();
			res.SetDescription("At least " + minimumNrMatchers + " of");
			System.Collections.IEnumerator ssi = subScorers.GetEnumerator();
			while (ssi.MoveNext())
			{
				res.AddDetail(((Scorer) ssi.Current).Explain(doc));
			}
			return res;
		}
            public virtual Explanation Explain(IndexReader reader, int doc)
            {
                ConstantScorer cs = (ConstantScorer) Scorer(reader);
                bool exists = cs.bits.Get(doc);

                Explanation result = new Explanation();

                if (exists)
                {
                    result.SetDescription("ConstantScoreQuery(" + Enclosing_Instance.filter + "), product of:");
                    result.SetValue(queryWeight);
                    result.AddDetail(new Explanation(Enclosing_Instance.GetBoost(), "boost"));
                    result.AddDetail(new Explanation(queryNorm, "queryNorm"));
                }
                else
                {
                    result.SetDescription("ConstantScoreQuery(" + Enclosing_Instance.filter + ") doesn't match id " + doc);
                    result.SetValue(0);
                }
                return result;
            }
Ejemplo n.º 25
0
                public override Explanation Explain(int doc)
                {
                    ComplexExplanation result = new ComplexExplanation();
                    Explanation nonPayloadExpl = base.Explain(doc);
                    result.AddDetail(nonPayloadExpl);
                    //QUESTION: Is there a wau to avoid this skipTo call?  We need to know whether to load the payload or not

                    Explanation payloadBoost = new Explanation();
                    result.AddDetail(payloadBoost);
                    /*
                    if (skipTo(doc) == true) {
                    processPayload();
                    }*/

                    float avgPayloadScore = (payloadsSeen > 0 ? (payloadScore / payloadsSeen) : 1);
                    payloadBoost.SetValue(avgPayloadScore);
                    //GSI: I suppose we could toString the payload, but I don't think that would be a good idea
                    payloadBoost.SetDescription("scorePayload(...)");
                    result.SetValue(nonPayloadExpl.GetValue() * avgPayloadScore);
                    result.SetDescription("btq, product of:");
                    result.SetMatch(nonPayloadExpl.GetValue() == 0 ? false : true); // LUCENE-1303
                    return result;
                }
Ejemplo n.º 26
0
		/// <returns> An explanation for the score of a given document. 
		/// </returns>
		public override Explanation Explain(int doc)
		{
			Explanation res = new Explanation();
			System.Collections.IEnumerator ssi = subScorers.GetEnumerator();
			float sumScore = 0.0f;
			int nrMatches = 0;
			while (ssi.MoveNext())
			{
				Explanation es = ((Scorer) ssi.Current).Explain(doc);
				if (es.GetValue() > 0.0f)
				{
					// indicates match
					sumScore += es.GetValue();
					nrMatches++;
				}
				res.AddDetail(es);
			}
			if (nrMatchers >= minimumNrMatchers)
			{
				res.SetValue(sumScore);
				res.SetDescription("sum over at least " + minimumNrMatchers + " of " + subScorers.Count + ":");
			}
			else
			{
				res.SetValue(0.0f);
				res.SetDescription(nrMatches + " match(es) but at least " + minimumNrMatchers + " of " + subScorers.Count + " needed");
			}
			return res;
		}
Ejemplo n.º 27
0
		public override Explanation Explain(int doc)
		{
			Explanation tfExplanation = new Explanation();
			
			while (Next() && Doc() < doc)
			{
			}
			
			float phraseFreq = (Doc() == doc)?freq:0.0f;
			tfExplanation.SetValue(GetSimilarity().Tf(phraseFreq));
			tfExplanation.SetDescription("tf(phraseFreq=" + phraseFreq + ")");
			
			return tfExplanation;
		}
Ejemplo n.º 28
0
			/* Explain the score we computed for doc */
			public virtual Explanation Explain(IndexReader reader, int doc)
			{
				if (Enclosing_Instance.disjuncts.Count == 1)
					return ((Weight) weights[0]).Explain(reader, doc);
				Explanation result = new Explanation();
				float max = 0.0f, sum = 0.0f;
				result.SetDescription(Enclosing_Instance.tieBreakerMultiplier == 0.0f ? "max of:" : "max plus " + Enclosing_Instance.tieBreakerMultiplier + " times others of:");
				for (int i = 0; i < weights.Count; i++)
				{
					Explanation e = ((Weight) weights[i]).Explain(reader, doc);
					if (e.GetValue() > 0)
					{
						result.AddDetail(e);
						sum += e.GetValue();
						max = System.Math.Max(max, e.GetValue());
					}
				}
				result.SetValue(max + (sum - max) * Enclosing_Instance.tieBreakerMultiplier);
				return result;
			}
Ejemplo n.º 29
0
            public virtual Explanation Explain(IndexReader reader, int doc)
            {
                ComplexExplanation result = new ComplexExplanation();

                result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");

                Explanation idfExpl = new Explanation(idf, "idf(docFreq=" + reader.DocFreq(Enclosing_Instance.term) + ", numDocs=" + reader.NumDocs() + ")");

                // explain query weight
                Explanation queryExpl = new Explanation();

                queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");

                Explanation boostExpl = new Explanation(Enclosing_Instance.GetBoost(), "boost");

                if (Enclosing_Instance.GetBoost() != 1.0f)
                {
                    queryExpl.AddDetail(boostExpl);
                }
                queryExpl.AddDetail(idfExpl);

                Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");

                queryExpl.AddDetail(queryNormExpl);

                queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());

                result.AddDetail(queryExpl);

                // explain field weight
                System.String      field     = Enclosing_Instance.term.Field();
                ComplexExplanation fieldExpl = new ComplexExplanation();

                fieldExpl.SetDescription("fieldWeight(" + Enclosing_Instance.term + " in " + doc + "), product of:");

                Explanation tfExpl = Scorer(reader).Explain(doc);

                fieldExpl.AddDetail(tfExpl);
                fieldExpl.AddDetail(idfExpl);

                Explanation fieldNormExpl = new Explanation();

                byte[] fieldNorms = reader.Norms(field);
                float  fieldNorm  = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]) : 0.0f;

                fieldNormExpl.SetValue(fieldNorm);
                fieldNormExpl.SetDescription("fieldNorm(field=" + field + ", doc=" + doc + ")");
                fieldExpl.AddDetail(fieldNormExpl);

                fieldExpl.SetMatch(tfExpl.IsMatch());
                fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());

                result.AddDetail(fieldExpl);
                System.Boolean tempAux = fieldExpl.GetMatch();
                result.SetMatch(tempAux);

                // combine them
                result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());

                if (queryExpl.GetValue() == 1.0f)
                {
                    return(fieldExpl);
                }

                return(result);
            }
Ejemplo n.º 30
0
		public override Explanation Explain(int doc)
		{
			Explanation tfExplanation = new Explanation();
			
			int d = Advance(doc);
			float phraseFreq = (d == doc)?freq:0.0f;
			tfExplanation.SetValue(GetSimilarity().Tf(phraseFreq));
			tfExplanation.SetDescription("tf(phraseFreq=" + phraseFreq + ")");
			
			return tfExplanation;
		}
 public override Explanation CustomExplain(int doc, Explanation subQueryExpl, Explanation[] valSrcExpls)
 {
     if (valSrcExpls.Length == 0)
     {
         return subQueryExpl;
     }
     Explanation exp = new Explanation(valSrcExpls[0].GetValue() + subQueryExpl.GetValue(), "sum of:");
     exp.AddDetail(subQueryExpl);
     exp.AddDetail(valSrcExpls[0]);
     if (valSrcExpls.Length == 1)
     {
         exp.SetDescription("CustomMulAdd, sum of:");
         return exp;
     }
     Explanation exp2 = new Explanation(valSrcExpls[1].GetValue() * exp.GetValue(), "custom score: product of:");
     exp2.AddDetail(valSrcExpls[1]);
     exp2.AddDetail(exp);
     return exp2;
 }
Ejemplo n.º 32
0
			public virtual Explanation Explain(IndexReader reader, int doc)
			{
				
				ComplexExplanation result = new ComplexExplanation();
				result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");
				
				Explanation idfExpl = new Explanation(idf, "idf(docFreq=" + reader.DocFreq(Enclosing_Instance.term) + ", numDocs=" + reader.NumDocs() + ")");
				
				// explain query weight
				Explanation queryExpl = new Explanation();
				queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");
				
				Explanation boostExpl = new Explanation(Enclosing_Instance.GetBoost(), "boost");
				if (Enclosing_Instance.GetBoost() != 1.0f)
					queryExpl.AddDetail(boostExpl);
				queryExpl.AddDetail(idfExpl);
				
				Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
				queryExpl.AddDetail(queryNormExpl);
				
				queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());
				
				result.AddDetail(queryExpl);
				
				// explain field weight
				System.String field = Enclosing_Instance.term.Field();
				ComplexExplanation fieldExpl = new ComplexExplanation();
				fieldExpl.SetDescription("fieldWeight(" + Enclosing_Instance.term + " in " + doc + "), product of:");
				
				Explanation tfExpl = Scorer(reader).Explain(doc);
				fieldExpl.AddDetail(tfExpl);
				fieldExpl.AddDetail(idfExpl);
				
				Explanation fieldNormExpl = new Explanation();
				byte[] fieldNorms = reader.Norms(field);
				float fieldNorm = fieldNorms != null ? Similarity.DecodeNorm(fieldNorms[doc]) : 0.0f;
				fieldNormExpl.SetValue(fieldNorm);
				fieldNormExpl.SetDescription("fieldNorm(field=" + field + ", doc=" + doc + ")");
				fieldExpl.AddDetail(fieldNormExpl);
				
				fieldExpl.SetMatch(tfExpl.IsMatch());
				fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());
				
				result.AddDetail(fieldExpl);
				System.Boolean tempAux = fieldExpl.GetMatch();
				result.SetMatch(tempAux);
				
				// combine them
				result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());
				
				if (queryExpl.GetValue() == 1.0f)
					return fieldExpl;
				
				return result;
			}
		/// <returns> An explanation for the score of a given document. 
		/// </returns>
		public override Explanation Explain(int doc)
		{
			Explanation res = new Explanation();
			float sumScore = 0.0f;
			int nrMatches = 0;
            foreach(Scorer s in subScorers)
            {
				Explanation es = s.Explain(doc);
				if (es.GetValue() > 0.0f)
				{
					// indicates match
					sumScore += es.GetValue();
					nrMatches++;
				}
				res.AddDetail(es);
			}
			if (nrMatchers >= minimumNrMatchers)
			{
				res.SetValue(sumScore);
				res.SetDescription("sum over at least " + minimumNrMatchers + " of " + subScorers.Count + ":");
			}
			else
			{
				res.SetValue(0.0f);
				res.SetDescription(nrMatches + " match(es) but at least " + minimumNrMatchers + " of " + subScorers.Count + " needed");
			}
			return res;
		}
Ejemplo n.º 34
0
			public virtual Explanation Explain(IndexReader reader, int doc)
			{
				Explanation result = new Explanation();
				result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");
				
				Explanation idfExpl = new Explanation(idf, "idf(" + GetQuery() + ")");
				
				// explain query weight
				Explanation queryExpl = new Explanation();
				queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");
				
				Explanation boostExpl = new Explanation(Enclosing_Instance.GetBoost(), "boost");
				if (Enclosing_Instance.GetBoost() != 1.0f)
					queryExpl.AddDetail(boostExpl);
				
				queryExpl.AddDetail(idfExpl);
				
				Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
				queryExpl.AddDetail(queryNormExpl);
				
				queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());
				
				result.AddDetail(queryExpl);
				
				// explain field weight
				Explanation fieldExpl = new Explanation();
				fieldExpl.SetDescription("fieldWeight(" + GetQuery() + " in " + doc + "), product of:");
				
				Explanation tfExpl = Scorer(reader).Explain(doc);
				fieldExpl.AddDetail(tfExpl);
				fieldExpl.AddDetail(idfExpl);
				
				Explanation fieldNormExpl = new Explanation();
				byte[] fieldNorms = reader.Norms(Enclosing_Instance.field);
				float fieldNorm = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]):0.0f;
				fieldNormExpl.SetValue(fieldNorm);
				fieldNormExpl.SetDescription("fieldNorm(field=" + Enclosing_Instance.field + ", doc=" + doc + ")");
				fieldExpl.AddDetail(fieldNormExpl);
				
				fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());
				
				result.AddDetail(fieldExpl);
				
				// combine them
				result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());
				
				if (queryExpl.GetValue() == 1.0f)
					return fieldExpl;
				
				return result;
			}
Ejemplo n.º 35
0
            public override Explanation Explain(IndexReader reader, int doc)
            {
                ComplexExplanation result = new ComplexExplanation();

                result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");

                Explanation idfExpl = new Explanation(idf, "idf(" + GetQuery() + ")");

                // explain query weight
                Explanation queryExpl = new Explanation();

                queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");

                Explanation boostExpl = new Explanation(Enclosing_Instance.GetBoost(), "boost");

                if (Enclosing_Instance.GetBoost() != 1.0f)
                {
                    queryExpl.AddDetail(boostExpl);
                }

                queryExpl.AddDetail(idfExpl);

                Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");

                queryExpl.AddDetail(queryNormExpl);

                queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());

                result.AddDetail(queryExpl);

                // explain field weight
                ComplexExplanation fieldExpl = new ComplexExplanation();

                fieldExpl.SetDescription("fieldWeight(" + GetQuery() + " in " + doc + "), product of:");

                Scorer scorer = Scorer(reader, true, false);

                if (scorer == null)
                {
                    return(new Explanation(0.0f, "no matching docs"));
                }
                Explanation tfExpl = scorer.Explain(doc);

                fieldExpl.AddDetail(tfExpl);
                fieldExpl.AddDetail(idfExpl);

                Explanation fieldNormExpl = new Explanation();

                byte[] fieldNorms = reader.Norms(Enclosing_Instance.field);
                float  fieldNorm  = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]) : 1.0f;

                fieldNormExpl.SetValue(fieldNorm);
                fieldNormExpl.SetDescription("fieldNorm(field=" + Enclosing_Instance.field + ", doc=" + doc + ")");
                fieldExpl.AddDetail(fieldNormExpl);

                fieldExpl.SetMatch(tfExpl.IsMatch());
                fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());

                result.AddDetail(fieldExpl);
                System.Boolean?tempAux = fieldExpl.GetMatch();
                result.SetMatch(tempAux);

                // combine them
                result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());

                if (queryExpl.GetValue() == 1.0f)
                {
                    return(fieldExpl);
                }

                return(result);
            }
Ejemplo n.º 36
0
        public virtual Explanation Explain(IndexReader reader, int doc)
        {
            ComplexExplanation result = new ComplexExplanation();
            result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");
            System.String field = ((SpanQuery) GetQuery()).GetField();

            System.Text.StringBuilder docFreqs = new System.Text.StringBuilder();
            System.Collections.IEnumerator i = terms.GetEnumerator();
            while (i.MoveNext())
            {
                System.Collections.DictionaryEntry tmp = (System.Collections.DictionaryEntry) i.Current;
                Term term = (Term) tmp.Key;
                docFreqs.Append(term.Text());
                docFreqs.Append("=");
                docFreqs.Append(reader.DocFreq(term));

                if (i.MoveNext())
                {
                    docFreqs.Append(" ");
                }
            }

            Explanation idfExpl = new Explanation(idf, "idf(" + field + ": " + docFreqs + ")");

            // explain query weight
            Explanation queryExpl = new Explanation();
            queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");

            Explanation boostExpl = new Explanation(GetQuery().GetBoost(), "boost");
            if (GetQuery().GetBoost() != 1.0f)
                queryExpl.AddDetail(boostExpl);
            queryExpl.AddDetail(idfExpl);

            Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
            queryExpl.AddDetail(queryNormExpl);

            queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());

            result.AddDetail(queryExpl);

            // explain field weight
            ComplexExplanation fieldExpl = new ComplexExplanation();
            fieldExpl.SetDescription("fieldWeight(" + field + ":" + query.ToString(field) + " in " + doc + "), product of:");

            Explanation tfExpl = Scorer(reader).Explain(doc);
            fieldExpl.AddDetail(tfExpl);
            fieldExpl.AddDetail(idfExpl);

            Explanation fieldNormExpl = new Explanation();
            byte[] fieldNorms = reader.Norms(field);
            float fieldNorm = fieldNorms != null ? Similarity.DecodeNorm(fieldNorms[doc]) : 0.0f;
            fieldNormExpl.SetValue(fieldNorm);
            fieldNormExpl.SetDescription("fieldNorm(field=" + field + ", doc=" + doc + ")");
            fieldExpl.AddDetail(fieldNormExpl);

            fieldExpl.SetMatch(tfExpl.IsMatch());
            fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());

            result.AddDetail(fieldExpl);
            System.Boolean tempAux = fieldExpl.GetMatch();
            result.SetMatch(tempAux);

            // combine them
            result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());

            if (queryExpl.GetValue() == 1.0f)
                return fieldExpl;

            return result;
        }
Ejemplo n.º 37
0
			public override Explanation Explain(IndexReader reader, int doc)
			{
				ComplexExplanation result = new ComplexExplanation();
				result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");
				
				Explanation idfExpl = new Explanation(idf, "idf(" + GetQuery() + ")");
				
				// explain query weight
				Explanation queryExpl = new Explanation();
				queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");
				
				Explanation boostExpl = new Explanation(Enclosing_Instance.GetBoost(), "boost");
				if (Enclosing_Instance.GetBoost() != 1.0f)
					queryExpl.AddDetail(boostExpl);
				
				queryExpl.AddDetail(idfExpl);
				
				Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
				queryExpl.AddDetail(queryNormExpl);
				
				queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());
				
				result.AddDetail(queryExpl);
				
				// explain field weight
				ComplexExplanation fieldExpl = new ComplexExplanation();
				fieldExpl.SetDescription("fieldWeight(" + GetQuery() + " in " + doc + "), product of:");
				
				Scorer scorer = Scorer(reader, true, false);
				if (scorer == null)
				{
					return new Explanation(0.0f, "no matching docs");
				}
				Explanation tfExpl = scorer.Explain(doc);
				fieldExpl.AddDetail(tfExpl);
				fieldExpl.AddDetail(idfExpl);
				
				Explanation fieldNormExpl = new Explanation();
				byte[] fieldNorms = reader.Norms(Enclosing_Instance.field);
				float fieldNorm = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]):1.0f;
				fieldNormExpl.SetValue(fieldNorm);
				fieldNormExpl.SetDescription("fieldNorm(field=" + Enclosing_Instance.field + ", doc=" + doc + ")");
				fieldExpl.AddDetail(fieldNormExpl);
				
				fieldExpl.SetMatch(tfExpl.IsMatch());
				fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());
				
				result.AddDetail(fieldExpl);
				System.Boolean? tempAux = fieldExpl.GetMatch();
				result.SetMatch(tempAux);
				
				// combine them
				result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());
				
				if (queryExpl.GetValue() == 1.0f)
					return fieldExpl;
				
				return result;
			}
Ejemplo n.º 38
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;
        }
Ejemplo n.º 39
0
            public virtual Explanation Explain(IndexReader reader, int doc)
            {
                Explanation sumExpl = new Explanation();

                sumExpl.SetDescription("sum of:");
                int   coord    = 0;
                int   maxCoord = 0;
                float sum      = 0.0f;

                for (int i = 0; i < weights.Count; i++)
                {
                    BooleanClause c = (BooleanClause)Enclosing_Instance.clauses[i];
                    Weight        w = (Weight)weights[i];
                    Explanation   e = w.Explain(reader, doc);
                    if (!c.IsProhibited())
                    {
                        maxCoord++;
                    }
                    if (e.GetValue() > 0)
                    {
                        if (!c.IsProhibited())
                        {
                            sumExpl.AddDetail(e);
                            sum += e.GetValue();
                            coord++;
                        }
                        else
                        {
                            return(new Explanation(0.0f, "match prohibited"));
                        }
                    }
                    else if (c.IsRequired())
                    {
                        return(new Explanation(0.0f, "match required"));
                    }
                }
                sumExpl.SetValue(sum);

                if (coord == 1)
                {
                    // only one clause matched
                    sumExpl = sumExpl.GetDetails()[0];                     // eliminate wrapper
                }
                float coordFactor = similarity.Coord(coord, maxCoord);

                if (coordFactor == 1.0f)
                {
                    // coord is no-op
                    return(sumExpl);
                }
                // eliminate wrapper
                else
                {
                    Explanation result = new Explanation();
                    result.SetDescription("product of:");
                    result.AddDetail(sumExpl);
                    result.AddDetail(new Explanation(coordFactor, "coord(" + coord + "/" + maxCoord + ")"));
                    result.SetValue(sum * coordFactor);
                    return(result);
                }
            }
Ejemplo n.º 40
0
			public virtual Explanation Explain(IndexReader reader, int doc)
			{
				// explain query weight
				Explanation queryExpl = new Explanation();
				queryExpl.SetDescription("MatchAllDocsQuery:");
				
				Explanation boostExpl = new Explanation(Enclosing_Instance.GetBoost(), "boost");
				if (Enclosing_Instance.GetBoost() != 1.0f)
					queryExpl.AddDetail(boostExpl);
				queryExpl.SetValue(boostExpl.GetValue());
				
				return queryExpl;
			}
Ejemplo n.º 41
0
            public virtual Explanation Explain(IndexReader reader, int doc)
            {
                Explanation sumExpl = new Explanation();
                sumExpl.SetDescription("sum of:");
                int coord = 0;
                int maxCoord = 0;
                float sum = 0.0f;
                for (int i = 0; i < weights.Count; i++)
                {
                    BooleanClause c = (BooleanClause) Enclosing_Instance.clauses[i];
                    Weight w = (Weight) weights[i];
                    Explanation e = w.Explain(reader, doc);
                    if (!c.IsProhibited())
                        maxCoord++;
                    if (e.GetValue() > 0)
                    {
                        if (!c.IsProhibited())
                        {
                            sumExpl.AddDetail(e);
                            sum += e.GetValue();
                            coord++;
                        }
                        else
                        {
                            return new Explanation(0.0f, "match prohibited");
                        }
                    }
                    else if (c.IsRequired())
                    {
                        return new Explanation(0.0f, "match required");
                    }
                }
                sumExpl.SetValue(sum);

                if (coord == 1)
                // only one clause matched
                    sumExpl = sumExpl.GetDetails()[0]; // eliminate wrapper

                float coordFactor = similarity.Coord(coord, maxCoord);
                if (coordFactor == 1.0f)
                // coord is no-op
                    return sumExpl;
                // eliminate wrapper
                else
                {
                    Explanation result = new Explanation();
                    result.SetDescription("product of:");
                    result.AddDetail(sumExpl);
                    result.AddDetail(new Explanation(coordFactor, "coord(" + coord + "/" + maxCoord + ")"));
                    result.SetValue(sum * coordFactor);
                    return result;
                }
            }
Ejemplo n.º 42
0
			public virtual Explanation Explain(IndexReader reader, int doc)
			{
				
				Explanation result = new Explanation();
				result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");
				
				System.Text.StringBuilder docFreqs = new System.Text.StringBuilder();
				System.Text.StringBuilder query = new System.Text.StringBuilder();
				query.Append('\"');
				for (int i = 0; i < Enclosing_Instance.terms.Count; i++)
				{
					if (i != 0)
					{
						docFreqs.Append(" ");
						query.Append(" ");
					}
					
					Term term = (Term) Enclosing_Instance.terms[i];
					
					docFreqs.Append(term.Text());
					docFreqs.Append("=");
					docFreqs.Append(reader.DocFreq(term));
					
					query.Append(term.Text());
				}
				query.Append('\"');
				
				Explanation idfExpl = new Explanation(idf, "idf(" + Enclosing_Instance.field + ": " + docFreqs + ")");
				
				// explain query weight
				Explanation queryExpl = new Explanation();
				queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");
				
				Explanation boostExpl = new Explanation(Enclosing_Instance.GetBoost(), "boost");
				if (Enclosing_Instance.GetBoost() != 1.0f)
					queryExpl.AddDetail(boostExpl);
				queryExpl.AddDetail(idfExpl);
				
				Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
				queryExpl.AddDetail(queryNormExpl);
				
				queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());
				
				result.AddDetail(queryExpl);
				
				// explain field weight
				Explanation fieldExpl = new Explanation();
				fieldExpl.SetDescription("fieldWeight(" + Enclosing_Instance.field + ":" + query + " in " + doc + "), product of:");
				
				Explanation tfExpl = Scorer(reader).Explain(doc);
				fieldExpl.AddDetail(tfExpl);
				fieldExpl.AddDetail(idfExpl);
				
				Explanation fieldNormExpl = new Explanation();
				byte[] fieldNorms = reader.Norms(Enclosing_Instance.field);
				float fieldNorm = fieldNorms != null ? Similarity.DecodeNorm(fieldNorms[doc]) : 0.0f;
				fieldNormExpl.SetValue(fieldNorm);
				fieldNormExpl.SetDescription("fieldNorm(field=" + Enclosing_Instance.field + ", doc=" + doc + ")");
				fieldExpl.AddDetail(fieldNormExpl);
				
				fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());
				
				result.AddDetail(fieldExpl);
				
				// combine them
				result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());
				
				if (queryExpl.GetValue() == 1.0f)
					return fieldExpl;
				
				return result;
			}
Ejemplo n.º 43
0
		public override Explanation Explain(int doc)
		{
			Explanation res = new Explanation();
			if (exclDisi.Advance(doc) == doc)
			{
				res.SetDescription("excluded");
			}
			else
			{
				res.SetDescription("not excluded");
				res.AddDetail(reqScorer.Explain(doc));
			}
			return res;
		}
Ejemplo n.º 44
0
            public virtual Explanation Explain(IndexReader reader, int doc)
            {
                Explanation result = new Explanation();

                result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");

                Explanation idfExpl = new Explanation(idf, "idf(" + GetQuery() + ")");

                // explain query weight
                Explanation queryExpl = new Explanation();

                queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");

                Explanation boostExpl = new Explanation(Enclosing_Instance.GetBoost(), "boost");

                if (Enclosing_Instance.GetBoost() != 1.0f)
                {
                    queryExpl.AddDetail(boostExpl);
                }

                queryExpl.AddDetail(idfExpl);

                Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");

                queryExpl.AddDetail(queryNormExpl);

                queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());

                result.AddDetail(queryExpl);

                // explain field weight
                Explanation fieldExpl = new Explanation();

                fieldExpl.SetDescription("fieldWeight(" + GetQuery() + " in " + doc + "), product of:");

                Explanation tfExpl = Scorer(reader).Explain(doc);

                fieldExpl.AddDetail(tfExpl);
                fieldExpl.AddDetail(idfExpl);

                Explanation fieldNormExpl = new Explanation();

                byte[] fieldNorms = reader.Norms(Enclosing_Instance.field);
                float  fieldNorm  = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]) : 0.0f;

                fieldNormExpl.SetValue(fieldNorm);
                fieldNormExpl.SetDescription("fieldNorm(field=" + Enclosing_Instance.field + ", doc=" + doc + ")");
                fieldExpl.AddDetail(fieldNormExpl);

                fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());

                result.AddDetail(fieldExpl);

                // combine them
                result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());

                if (queryExpl.GetValue() == 1.0f)
                {
                    return(fieldExpl);
                }

                return(result);
            }
Ejemplo n.º 45
0
            public override Explanation Explain(IndexReader reader, int doc)
            {
                Explanation result = new Explanation();

                result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");

                System.Text.StringBuilder docFreqs = new System.Text.StringBuilder();
                System.Text.StringBuilder query    = new System.Text.StringBuilder();
                query.Append('\"');
                docFreqs.Append(idfExp.Explain());
                for (int i = 0; i < Enclosing_Instance.terms.Count; i++)
                {
                    if (i != 0)
                    {
                        query.Append(" ");
                    }

                    Term term = (Term)Enclosing_Instance.terms[i];

                    query.Append(term.Text());
                }
                query.Append('\"');

                Explanation idfExpl = new Explanation(idf, "idf(" + Enclosing_Instance.field + ":" + docFreqs + ")");

                // explain query weight
                Explanation queryExpl = new Explanation();

                queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");

                Explanation boostExpl = new Explanation(Enclosing_Instance.GetBoost(), "boost");

                if (Enclosing_Instance.GetBoost() != 1.0f)
                {
                    queryExpl.AddDetail(boostExpl);
                }
                queryExpl.AddDetail(idfExpl);

                Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");

                queryExpl.AddDetail(queryNormExpl);

                queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());

                result.AddDetail(queryExpl);

                // explain field weight
                Explanation fieldExpl = new Explanation();

                fieldExpl.SetDescription("fieldWeight(" + Enclosing_Instance.field + ":" + query + " in " + doc + "), product of:");

                Scorer scorer = Scorer(reader, true, false);

                if (scorer == null)
                {
                    return(new Explanation(0.0f, "no matching docs"));
                }
                Explanation tfExpl = scorer.Explain(doc);

                fieldExpl.AddDetail(tfExpl);
                fieldExpl.AddDetail(idfExpl);

                Explanation fieldNormExpl = new Explanation();

                byte[] fieldNorms = reader.Norms(Enclosing_Instance.field);
                float  fieldNorm  = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]) : 1.0f;

                fieldNormExpl.SetValue(fieldNorm);
                fieldNormExpl.SetDescription("fieldNorm(field=" + Enclosing_Instance.field + ", doc=" + doc + ")");
                fieldExpl.AddDetail(fieldNormExpl);

                fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());

                result.AddDetail(fieldExpl);

                // combine them
                result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());

                if (queryExpl.GetValue() == 1.0f)
                {
                    return(fieldExpl);
                }

                return(result);
            }
Ejemplo n.º 46
0
		public override Explanation Explain(int doc)
		{
			Explanation e = new Explanation();
			e.SetDescription("No document matches.");
			return e;
		}
            public virtual Explanation Explain(IndexReader reader, int doc)
            {
                // explain query weight
                Explanation queryExpl = new Explanation();
                queryExpl.SetDescription("MatchAllDocsQuery, product of:");
                queryExpl.SetValue(GetValue());
                if (Enclosing_Instance.GetBoost() != 1.0f)
                {
                    queryExpl.AddDetail(new Explanation(Enclosing_Instance.GetBoost(), "boost"));
                }
                queryExpl.AddDetail(new Explanation(queryNorm, "queryNorm"));

                return queryExpl;
            }