Beispiel #1
0
            private Explanation DoExplain(IndexReader reader, int doc)
            {
                Scorer[] valSrcScorers = new Scorer[valSrcWeights.Length];
                for (int i = 0; i < valSrcScorers.Length; i++)
                {
                    valSrcScorers[i] = valSrcWeights[i].Scorer(reader, true, false);
                }
                Explanation subQueryExpl = subQueryWeight.Explain(reader, doc);

                if (!subQueryExpl.IsMatch())
                {
                    return(subQueryExpl);
                }
                // match
                Explanation[] valSrcExpls = new Explanation[valSrcScorers.Length];
                for (int i = 0; i < valSrcScorers.Length; i++)
                {
                    valSrcExpls[i] = valSrcScorers[i].Explain(doc);
                }
                Explanation customExp = Enclosing_Instance.GetCustomScoreProvider(reader).CustomExplain(doc, subQueryExpl, valSrcExpls);
                float       sc        = GetValue() * customExp.GetValue();
                Explanation res       = new ComplexExplanation(true, sc, Enclosing_Instance.ToString() + ", product of:");

                res.AddDetail(customExp);
                res.AddDetail(new Explanation(GetValue(), "queryBoost"));                 // actually using the q boost as q weight (== weight value)
                return(res);
            }
Beispiel #2
0
        public virtual Explanation CustomExplain(int doc, Explanation subQueryExpl, Explanation[] valSrcExpls)
        {
            if (valSrcExpls.Length == 1)
            {
                return(CustomExplain(doc, subQueryExpl, valSrcExpls[0]));
            }
            if (valSrcExpls.Length == 0)
            {
                return(subQueryExpl);
            }
            float valSrcScore = 1;

            for (int i = 0; i < valSrcExpls.Length; i++)
            {
                valSrcScore *= valSrcExpls[i].GetValue();
            }
            Explanation exp = new Explanation(valSrcScore * subQueryExpl.GetValue(), "custom score: product of:");

            exp.AddDetail(subQueryExpl);
            for (int i = 0; i < valSrcExpls.Length; i++)
            {
                exp.AddDetail(valSrcExpls[i]);
            }
            return(exp);
        }
Beispiel #3
0
        public override Explanation Explain(int doc)
        {
            Explanation tfExplanation = new Explanation();

            int expDoc = Advance(doc);

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

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

            return(tfExplanation);
        }
Beispiel #4
0
        public virtual Explanation CustomExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpl)
        {
            float valSrcScore = 1;

            if (valSrcExpl != null)
            {
                valSrcScore *= valSrcExpl.GetValue();
            }
            Explanation exp = new Explanation(valSrcScore * subQueryExpl.GetValue(), "custom score: product of:");

            exp.AddDetail(subQueryExpl);
            exp.AddDetail(valSrcExpl);
            return(exp);
        }
Beispiel #5
0
            public override Explanation Explain(int doc)
            {
                Explanation result         = new Explanation();
                Explanation nonPayloadExpl = base.Explain(doc);

                result.AddDetail(nonPayloadExpl);
                Explanation payloadBoost = new Explanation();

                result.AddDetail(payloadBoost);
                float avgPayloadScore = (payloadsSeen > 0?(payloadScore / payloadsSeen):1);

                payloadBoost.SetValue(avgPayloadScore);
                payloadBoost.SetDescription("scorePayload(...)");
                result.SetValue(nonPayloadExpl.GetValue() * avgPayloadScore);
                result.SetDescription("bnq, product of:");
                return(result);
            }
Beispiel #6
0
            // TODO: remove in 3.0
            /*(non-Javadoc) @see Mono.Lucene.Net.Search.Scorer#explain(int) */
            public override Explanation Explain(int doc)
            {
                Explanation subQueryExpl = weight.subQueryWeight.Explain(reader, doc);

                if (!subQueryExpl.IsMatch())
                {
                    return(subQueryExpl);
                }
                // match
                Explanation[] valSrcExpls = new Explanation[valSrcScorers.Length];
                for (int i = 0; i < valSrcScorers.Length; i++)
                {
                    valSrcExpls[i] = valSrcScorers[i].Explain(doc);
                }
                Explanation customExp = Enclosing_Instance.CustomExplain(doc, subQueryExpl, valSrcExpls);
                float       sc        = qWeight * customExp.GetValue();
                Explanation res       = new ComplexExplanation(true, sc, Enclosing_Instance.ToString() + ", product of:");

                res.AddDetail(customExp);
                res.AddDetail(new Explanation(qWeight, "queryBoost"));                 // actually using the q boost as q weight (== weight value)
                return(res);
            }
Beispiel #7
0
                public override Explanation Explain(int doc)
                {
                    ComplexExplanation result         = new ComplexExplanation();
                    Explanation        nonPayloadExpl = base.Explain(doc);

                    result.AddDetail(nonPayloadExpl);
                    // QUESTION: Is there a way to avoid this skipTo call? We need to know
                    // whether to load the payload or not
                    Explanation payloadBoost = new Explanation();

                    result.AddDetail(payloadBoost);

                    float payloadScore = GetPayloadScore();

                    payloadBoost.SetValue(payloadScore);
                    // 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() * payloadScore);
                    result.SetDescription("btq, product of:");
                    result.SetMatch(nonPayloadExpl.GetValue() == 0?false:true);                     // LUCENE-1303
                    return(result);
                }
Beispiel #8
0
			public override Explanation Explain(int doc)
			{
				Explanation result = new Explanation();
				Explanation nonPayloadExpl = base.Explain(doc);
				result.AddDetail(nonPayloadExpl);
				Explanation payloadBoost = new Explanation();
				result.AddDetail(payloadBoost);
				float avgPayloadScore = (payloadsSeen > 0?(payloadScore / payloadsSeen):1);
				payloadBoost.SetValue(avgPayloadScore);
				payloadBoost.SetDescription("scorePayload(...)");
				result.SetValue(nonPayloadExpl.GetValue() * avgPayloadScore);
				result.SetDescription("bnq, product of:");
				return result;
			}
Beispiel #9
0
		public override Explanation Explain(int doc)
		{
			Explanation tfExplanation = new Explanation();
			
			int expDoc = Advance(doc);
			
			float phraseFreq = (expDoc == doc)?freq:0.0f;
			tfExplanation.SetValue(GetSimilarity().Tf(phraseFreq));
			tfExplanation.SetDescription("tf(phraseFreq=" + phraseFreq + ")");
			
			return tfExplanation;
		}
Beispiel #10
0
			// TODO: remove in 3.0
			/*(non-Javadoc) @see Mono.Lucene.Net.Search.Scorer#explain(int) */
			public override Explanation Explain(int doc)
			{
				Explanation subQueryExpl = weight.subQueryWeight.Explain(reader, doc);
				if (!subQueryExpl.IsMatch())
				{
					return subQueryExpl;
				}
				// match
				Explanation[] valSrcExpls = new Explanation[valSrcScorers.Length];
				for (int i = 0; i < valSrcScorers.Length; i++)
				{
					valSrcExpls[i] = valSrcScorers[i].Explain(doc);
				}
				Explanation customExp = Enclosing_Instance.CustomExplain(doc, subQueryExpl, valSrcExpls);
				float sc = qWeight * customExp.GetValue();
				Explanation res = new ComplexExplanation(true, sc, Enclosing_Instance.ToString() + ", product of:");
				res.AddDetail(customExp);
				res.AddDetail(new Explanation(qWeight, "queryBoost")); // actually using the q boost as q weight (== weight value)
				return res;
			}
Beispiel #11
0
			private Explanation DoExplain(IndexReader reader, int doc)
			{
				Scorer[] valSrcScorers = new Scorer[valSrcWeights.Length];
				for (int i = 0; i < valSrcScorers.Length; i++)
				{
					valSrcScorers[i] = valSrcWeights[i].Scorer(reader, true, false);
				}
				Explanation subQueryExpl = subQueryWeight.Explain(reader, doc);
				if (!subQueryExpl.IsMatch())
				{
					return subQueryExpl;
				}
				// match
				Explanation[] valSrcExpls = new Explanation[valSrcScorers.Length];
				for (int i = 0; i < valSrcScorers.Length; i++)
				{
					valSrcExpls[i] = valSrcScorers[i].Explain(doc);
				}
                Explanation customExp = Enclosing_Instance.GetCustomScoreProvider(reader).CustomExplain(doc, subQueryExpl, valSrcExpls);
				float sc = GetValue() * customExp.GetValue();
				Explanation res = new ComplexExplanation(true, sc, Enclosing_Instance.ToString() + ", product of:");
				res.AddDetail(customExp);
				res.AddDetail(new Explanation(GetValue(), "queryBoost")); // actually using the q boost as q weight (== weight value)
				return res;
			}
Beispiel #12
0
		public virtual Explanation CustomExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpl)
		{
			float valSrcScore = 1;
			if (valSrcExpl != null)
			{
				valSrcScore *= valSrcExpl.GetValue();
			}
			Explanation exp = new Explanation(valSrcScore * subQueryExpl.GetValue(), "custom score: product of:");
			exp.AddDetail(subQueryExpl);
			exp.AddDetail(valSrcExpl);
			return exp;
		}
Beispiel #13
0
 public override Explanation CustomExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpl)
 {
     return parent.CustomExplain(doc, subQueryExpl, valSrcExpl);
 }
Beispiel #14
0
				public override Explanation Explain(int doc)
				{
					ComplexExplanation result = new ComplexExplanation();
					Explanation nonPayloadExpl = base.Explain(doc);
					result.AddDetail(nonPayloadExpl);
					// QUESTION: Is there a way to avoid this skipTo call? We need to know
					// whether to load the payload or not
					Explanation payloadBoost = new Explanation();
					result.AddDetail(payloadBoost);
					
					float payloadScore = GetPayloadScore();
					payloadBoost.SetValue(payloadScore);
					// 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() * payloadScore);
					result.SetDescription("btq, product of:");
					result.SetMatch(nonPayloadExpl.GetValue() == 0?false:true); // LUCENE-1303
					return result;
				}
Beispiel #15
0
            public override Explanation Explain(IndexReader reader, int doc)
            {
                Explanation explain = DoExplain(reader, doc);

                return(explain == null?new Explanation(0.0f, "no matching docs"):explain);
            }
Beispiel #16
0
		public virtual Explanation CustomExplain(int doc, Explanation subQueryExpl, Explanation[] valSrcExpls)
		{
			if (valSrcExpls.Length == 1)
			{
				return CustomExplain(doc, subQueryExpl, valSrcExpls[0]);
			}
			if (valSrcExpls.Length == 0)
			{
				return subQueryExpl;
			}
			float valSrcScore = 1;
			for (int i = 0; i < valSrcExpls.Length; i++)
			{
				valSrcScore *= valSrcExpls[i].GetValue();
			}
			Explanation exp = new Explanation(valSrcScore * subQueryExpl.GetValue(), "custom score: product of:");
			exp.AddDetail(subQueryExpl);
			for (int i = 0; i < valSrcExpls.Length; i++)
			{
				exp.AddDetail(valSrcExpls[i]);
			}
			return exp;
		}
Beispiel #17
0
 public override Explanation CustomExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpl)
 {
     return(parent.CustomExplain(doc, subQueryExpl, valSrcExpl));
 }