internal TFIDFSimScorer(TFIDFSimilarity outerInstance, IDFStats stats, NumericDocValues norms) { this.outerInstance = outerInstance; this.stats = stats; this.weightValue = stats.Value; this.norms = norms; }
private Explanation ExplainScore(int doc, Explanation freq, IDFStats stats, NumericDocValues norms) { Explanation result = new Explanation(); result.Description = "score(doc=" + doc + ",freq=" + freq + "), product of:"; // explain query weight Explanation queryExpl = new Explanation(); queryExpl.Description = "queryWeight, product of:"; Explanation boostExpl = new Explanation(stats.QueryBoost, "boost"); if (stats.QueryBoost != 1.0f) { queryExpl.AddDetail(boostExpl); } queryExpl.AddDetail(stats.Idf); Explanation queryNormExpl = new Explanation(stats.QueryNorm, "queryNorm"); queryExpl.AddDetail(queryNormExpl); queryExpl.Value = boostExpl.Value * stats.Idf.Value * queryNormExpl.Value; result.AddDetail(queryExpl); // explain field weight Explanation fieldExpl = new Explanation(); fieldExpl.Description = "fieldWeight in " + doc + ", product of:"; Explanation tfExplanation = new Explanation(); tfExplanation.Value = Tf(freq.Value); tfExplanation.Description = "tf(freq=" + freq.Value + "), with freq of:"; tfExplanation.AddDetail(freq); fieldExpl.AddDetail(tfExplanation); fieldExpl.AddDetail(stats.Idf); Explanation fieldNormExpl = new Explanation(); float fieldNorm = norms != null?DecodeNormValue(norms.Get(doc)) : 1.0f; fieldNormExpl.Value = fieldNorm; fieldNormExpl.Description = "fieldNorm(doc=" + doc + ")"; fieldExpl.AddDetail(fieldNormExpl); fieldExpl.Value = tfExplanation.Value * stats.Idf.Value * fieldNormExpl.Value; result.AddDetail(fieldExpl); // combine them result.Value = queryExpl.Value * fieldExpl.Value; if (queryExpl.Value == 1.0f) { return(fieldExpl); } return(result); }
public override sealed SimScorer GetSimScorer(SimWeight stats, AtomicReaderContext context) { IDFStats idfstats = (IDFStats)stats; return(new TFIDFSimScorer(this, idfstats, context.AtomicReader.GetNormValues(idfstats.Field))); }
private Explanation ExplainScore(int doc, Explanation freq, IDFStats stats, NumericDocValues norms) { Explanation result = new Explanation(); // LUCENENET specific - using freq.Value is a change that was made in Lucene 5.0, but is included // in 4.8.0 to remove annoying newlines from the output. // See: https://github.com/apache/lucene-solr/commit/f0bfcbc7d8fbc5bb2791da60af559e8b0ad6eed6 result.Description = "score(doc=" + doc + ",freq=" + freq.Value + "), product of:"; // explain query weight Explanation queryExpl = new Explanation(); queryExpl.Description = "queryWeight, product of:"; Explanation boostExpl = new Explanation(stats.QueryBoost, "boost"); if (stats.QueryBoost != 1.0f) { queryExpl.AddDetail(boostExpl); } queryExpl.AddDetail(stats.Idf); Explanation queryNormExpl = new Explanation(stats.QueryNorm, "queryNorm"); queryExpl.AddDetail(queryNormExpl); queryExpl.Value = boostExpl.Value * stats.Idf.Value * queryNormExpl.Value; result.AddDetail(queryExpl); // explain field weight Explanation fieldExpl = new Explanation(); fieldExpl.Description = "fieldWeight in " + doc + ", product of:"; Explanation tfExplanation = new Explanation(); tfExplanation.Value = Tf(freq.Value); tfExplanation.Description = "tf(freq=" + freq.Value + "), with freq of:"; tfExplanation.AddDetail(freq); fieldExpl.AddDetail(tfExplanation); fieldExpl.AddDetail(stats.Idf); Explanation fieldNormExpl = new Explanation(); float fieldNorm = norms != null?DecodeNormValue(norms.Get(doc)) : 1.0f; fieldNormExpl.Value = fieldNorm; fieldNormExpl.Description = "fieldNorm(doc=" + doc + ")"; fieldExpl.AddDetail(fieldNormExpl); fieldExpl.Value = tfExplanation.Value * stats.Idf.Value * fieldNormExpl.Value; result.AddDetail(fieldExpl); // combine them result.Value = queryExpl.Value * fieldExpl.Value; if (queryExpl.Value == 1.0f) { return(fieldExpl); } return(result); }
internal TFIDFSimScorer(TFIDFSimilarity outerInstance, IDFStats stats, NumericDocValues norms) { this.OuterInstance = outerInstance; this.Stats = stats; this.WeightValue = stats.Value; this.Norms = norms; }
private Explanation ExplainScore(int doc, Explanation freq, IDFStats stats, NumericDocValues norms) { Explanation result = new Explanation(); result.Description = "score(doc=" + doc + ",freq=" + freq + "), product of:"; // explain query weight Explanation queryExpl = new Explanation(); queryExpl.Description = "queryWeight, product of:"; Explanation boostExpl = new Explanation(stats.QueryBoost, "boost"); if (stats.QueryBoost != 1.0f) { queryExpl.AddDetail(boostExpl); } queryExpl.AddDetail(stats.Idf); Explanation queryNormExpl = new Explanation(stats.QueryNorm, "queryNorm"); queryExpl.AddDetail(queryNormExpl); queryExpl.Value = boostExpl.Value * stats.Idf.Value * queryNormExpl.Value; result.AddDetail(queryExpl); // explain field weight Explanation fieldExpl = new Explanation(); fieldExpl.Description = "fieldWeight in " + doc + ", product of:"; Explanation tfExplanation = new Explanation(); tfExplanation.Value = Tf(freq.Value); tfExplanation.Description = "tf(freq=" + freq.Value + "), with freq of:"; tfExplanation.AddDetail(freq); fieldExpl.AddDetail(tfExplanation); fieldExpl.AddDetail(stats.Idf); Explanation fieldNormExpl = new Explanation(); float fieldNorm = norms != null ? DecodeNormValue(norms.Get(doc)) : 1.0f; fieldNormExpl.Value = fieldNorm; fieldNormExpl.Description = "fieldNorm(doc=" + doc + ")"; fieldExpl.AddDetail(fieldNormExpl); fieldExpl.Value = tfExplanation.Value * stats.Idf.Value * fieldNormExpl.Value; result.AddDetail(fieldExpl); // combine them result.Value = queryExpl.Value * fieldExpl.Value; if (queryExpl.Value == 1.0f) { return fieldExpl; } return result; }