use of org.apache.lucene.search.Explanation in project lucene-solr by apache.
the class DFRSimilarity method explain.
@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));
}
use of org.apache.lucene.search.Explanation in project lucene-solr by apache.
the class LMDirichletSimilarity method explain.
@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"));
}
subs.add(Explanation.match(mu, "mu"));
Explanation weightExpl = Explanation.match((float) Math.log(1 + freq / (mu * ((LMStats) stats).getCollectionProbability())), "term weight");
subs.add(weightExpl);
subs.add(Explanation.match((float) Math.log(mu / (docLen + mu)), "document norm"));
super.explain(subs, stats, doc, freq, docLen);
}
use of org.apache.lucene.search.Explanation in project lucene-solr by apache.
the class TFIDFSimilarity method computeWeight.
@Override
public final SimWeight computeWeight(float boost, CollectionStatistics collectionStats, TermStatistics... termStats) {
final Explanation idf = termStats.length == 1 ? idfExplain(collectionStats, termStats[0]) : idfExplain(collectionStats, termStats);
float[] normTable = new float[256];
for (int i = 1; i < 256; ++i) {
int length = SmallFloat.byte4ToInt((byte) i);
float norm = lengthNorm(length);
normTable[i] = norm;
}
normTable[0] = 1f / normTable[255];
return new IDFStats(collectionStats.field(), boost, idf, normTable);
}
use of org.apache.lucene.search.Explanation in project lucene-solr by apache.
the class TFIDFSimilarity method explainField.
private Explanation explainField(int doc, Explanation freq, IDFStats stats, NumericDocValues norms, float[] normTable) throws IOException {
Explanation tfExplanation = Explanation.match(tf(freq.getValue()), "tf(freq=" + freq.getValue() + "), with freq of:", freq);
float norm;
if (norms == null) {
norm = 1f;
} else if (norms.advanceExact(doc) == false) {
norm = 0f;
} else {
norm = normTable[(int) (norms.longValue() & 0xFF)];
}
Explanation fieldNormExpl = Explanation.match(norm, "fieldNorm(doc=" + doc + ")");
return Explanation.match(tfExplanation.getValue() * stats.idf.getValue() * fieldNormExpl.getValue(), "fieldWeight in " + doc + ", product of:", tfExplanation, stats.idf, fieldNormExpl);
}
use of org.apache.lucene.search.Explanation in project lucene-solr by apache.
the class TFIDFSimilarity method explainScore.
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);
}
Aggregations