lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1180599 - /lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/similarities/BM25Similarity.java
Date Sun, 09 Oct 2011 12:50:06 GMT
Author: rmuir
Date: Sun Oct  9 12:50:06 2011
New Revision: 1180599

URL: http://svn.apache.org/viewvc?rev=1180599&view=rev
Log:
fix explain to factor in outer boost

Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/similarities/BM25Similarity.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/similarities/BM25Similarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/similarities/BM25Similarity.java?rev=1180599&r1=1180598&r2=1180599&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/similarities/BM25Similarity.java
(original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/similarities/BM25Similarity.java
Sun Oct  9 12:50:06 2011
@@ -277,6 +277,8 @@ public class BM25Similarity extends Simi
     private final float avgdl;
     /** query's inner boost */
     private final float queryBoost;
+    /** query's outer boost (only for explain) */
+    private float topLevelBoost;
     /** weight (idf * boost) */
     private float weight;
     /** precomputed norm[256] with k1 * ((1 - b) + b * dl / avgdl) */
@@ -299,6 +301,7 @@ public class BM25Similarity extends Simi
     @Override
     public void normalize(float queryNorm, float topLevelBoost) {
       // we don't normalize with queryNorm at all, we just capture the top-level boost
+      this.topLevelBoost = topLevelBoost;
       this.weight = idf.getValue() * queryBoost * topLevelBoost;
     } 
   }
@@ -307,8 +310,8 @@ public class BM25Similarity extends Simi
     Explanation result = new Explanation();
     result.setDescription("score(doc="+doc+",freq="+freq+"), product of:");
     
-    Explanation boostExpl = new Explanation(stats.queryBoost, "boost");
-    if (stats.queryBoost != 1.0f)
+    Explanation boostExpl = new Explanation(stats.queryBoost * stats.topLevelBoost, "boost");
+    if (boostExpl.getValue() != 1.0f)
       result.addDetail(boostExpl);
     
     result.addDetail(stats.idf);



Mime
View raw message