@Override public final Explanation explain(BasicStats stats, float tf, float len) { return Explanation.match(1, "no normalization"); }
@Override Explanation explain(String field, String feature, float weight, int doc, int freq) throws IOException { float featureValue = decodeFeatureValue(freq); float score = scorer(field, weight).score(doc, freq); return Explanation.match(score, "Sigmoid function on the " + field + " field for the " + feature + " feature, computed as w * S^a / (S^a + k^a) from:", Explanation.match(weight, "w, weight of this function"), Explanation.match(pivot, "k, pivot feature value that would give a score contribution equal to w/2"), Explanation.match(pivot, "a, exponent, higher values make the function grow slower before k and faster after k"), Explanation.match(featureValue, "S, feature value")); } }
@Override Explanation explain(String field, String feature, float w, int doc, int freq) throws IOException { float featureValue = decodeFeatureValue(freq); float score = scorer(field, w).score(doc, freq); return Explanation.match(score, "Log function on the " + field + " field for the " + feature + " feature, computed as w * log(a + S) from:", Explanation.match(w, "w, weight of this function"), Explanation.match(scalingFactor, "a, scaling factor"), Explanation.match(featureValue, "S, feature value")); } }
@Override Explanation explain(String field, String feature, float weight, int doc, int freq) throws IOException { float featureValue = decodeFeatureValue(freq); float score = scorer(field, weight).score(doc, freq); return Explanation.match(score, "Saturation function on the " + field + " field for the " + feature + " feature, computed as w * S / (S + k) from:", Explanation.match(weight, "w, weight of this function"), Explanation.match(pivot, "k, pivot feature value that would give a score contribution equal to w/2"), Explanation.match(featureValue, "S, feature value")); } }
@Override public Explanation explain(int doc, Explanation freq) throws IOException { Explanation queryBoostExpl = Explanation.match(boost, "query boost"); return Explanation.match( queryBoostExpl.getValue(), "score(" + getClass().getSimpleName() + ", doc=" + doc + "), computed from:", queryBoostExpl); }
@Override public final Explanation explain(BasicStats stats, float tfn) { return Explanation.match( score(stats, tfn), getClass().getSimpleName() + ", computed from: ", Explanation.match(tfn, "tfn"), Explanation.match(stats.getTotalTermFreq(), "totalTermFreq"), Explanation.match(stats.getDocFreq(), "docFreq")); }
@Override protected void explain(List<Explanation> subExpls, BasicStats stats, int doc, float freq, float docLen) { subExpls.add(Explanation.match(collectionModel.computeProbability(stats), "collection probability")); }
/** Explains the score. Returns the name of the model only, since * both {@code tfn} and {@code lambda} are explained elsewhere. */ public Explanation explain(BasicStats stats, float tfn, float lambda) { return Explanation.match( score(stats, tfn, lambda), getClass().getSimpleName()); }
@Override public Explanation idfExplain(CollectionStatistics collectionStats, TermStatistics termStats) { final long df = termStats.docFreq(); final long docCount = collectionStats.docCount() == -1 ? collectionStats.maxDoc() : collectionStats.docCount(); final float idf = idf(df, docCount); return Explanation.match(idf, "idf, computed as log((docCount+1)/(docFreq+1)) + 1 from:", Explanation.match(df, "docFreq"), Explanation.match(docCount, "docCount")); }
private Explanation explainScore(int doc, Explanation freq, BM25Stats stats, NumericDocValues norms, float[] lengthCache) throws IOException { Explanation boostExpl = Explanation.match(stats.boost, "boost"); List<Explanation> subs = new ArrayList<>(); if (boostExpl.getValue() != 1.0f) subs.add(boostExpl); subs.add(stats.idf); Explanation tfNormExpl = explainTFNorm(doc, freq, stats, norms, lengthCache); subs.add(tfNormExpl); return Explanation.match( boostExpl.getValue() * stats.idf.getValue() * tfNormExpl.getValue(), "score(doc="+doc+",freq="+freq+"), product of:", subs); }
private Explanation explainScore(int doc, Explanation freq, IDFStats stats, NumericDocValues norms, float[] normTable) throws IOException { Explanation queryExpl = Explanation.match(stats.boost, "boost"); Explanation fieldExpl = explainField(doc, freq, stats, norms, normTable); if (stats.boost == 1f) { return fieldExpl; } return Explanation.match( queryExpl.getValue() * fieldExpl.getValue(), "score(doc="+doc+",freq="+freq.getValue()+"), product of:", queryExpl, fieldExpl); } }
@Override public Explanation explain(int doc, Explanation freq) throws IOException { List<Explanation> subs = new ArrayList<>(); for (SimScorer subScorer : subScorers) { subs.add(subScorer.explain(doc, freq)); } return Explanation.match(score(doc, freq.getValue()), "sum of:", subs); }
@Override protected void explain(List<Explanation> subs, BasicStats stats, int doc, float freq, float docLen) { if (stats.getBoost() != 1.0f) { subs.add(Explanation.match(stats.getBoost(), "boost")); } Explanation normExpl = normalization.explain(stats, freq, docLen); float tfn = normExpl.getValue(); subs.add(normExpl); subs.add(basicModel.explain(stats, tfn)); subs.add(afterEffect.explain(stats, tfn)); }
@Override protected void explain( List<Explanation> subs, BasicStats stats, int doc, float freq, float docLen) { if (stats.getBoost() != 1.0f) { subs.add(Explanation.match(stats.getBoost(), "boost")); } Explanation normExpl = normalization.explain(stats, freq, docLen); Explanation lambdaExpl = lambda.explain(stats); subs.add(normExpl); subs.add(lambdaExpl); subs.add(distribution.explain(stats, normExpl.getValue(), lambdaExpl.getValue())); }
@Override public Explanation explain(LeafReaderContext ctx, int docId, Explanation scoreExplanation) throws IOException { DoubleValues values = getValues(ctx, null); if (values.advanceExact(docId)) return Explanation.match((float) values.doubleValue(), this.toString()); else return Explanation.noMatch(this.toString()); }