lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r829000 - in /lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene: index/TestOmitTf.java search/TestSimilarity.java search/TestTermVectors.java search/payloads/TestPayloadNearQuery.java
Date Fri, 23 Oct 2009 11:23:04 GMT
Author: uschindler
Date: Fri Oct 23 11:23:04 2009
New Revision: 829000

URL: http://svn.apache.org/viewvc?rev=829000&view=rev
Log:
LUCENE-1973: Remove Similarity deprecations in backwards branch

Modified:
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestOmitTf.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSimilarity.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestTermVectors.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestOmitTf.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestOmitTf.java?rev=829000&r1=828999&r2=829000&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestOmitTf.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestOmitTf.java
Fri Oct 23 11:23:04 2009
@@ -36,6 +36,7 @@
 import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.search.Explanation.IDFExplanation;
 
 
 public class TestOmitTf extends LuceneTestCase {
@@ -43,13 +44,20 @@
   public static class SimpleSimilarity extends Similarity {
     public float lengthNorm(String field, int numTerms) { return 1.0f; }
     public float queryNorm(float sumOfSquaredWeights) { return 1.0f; }
-    
     public float tf(float freq) { return freq; }
-    
     public float sloppyFreq(int distance) { return 2.0f; }
-    public float idf(Collection terms, Searcher searcher) { return 1.0f; }
     public float idf(int docFreq, int numDocs) { return 1.0f; }
     public float coord(int overlap, int maxOverlap) { return 1.0f; }
+    public IDFExplanation idfExplain(Collection terms, Searcher searcher) throws IOException
{
+      return new IDFExplanation() {
+        public float getIdf() {
+          return 1.0f;
+        }
+        public String explain() {
+          return "Inexplicable";
+        }
+      };
+    }
   }
 
 

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSimilarity.java?rev=829000&r1=828999&r2=829000&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSimilarity.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSimilarity.java
Fri Oct 23 11:23:04 2009
@@ -29,6 +29,7 @@
 import org.apache.lucene.analysis.SimpleAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.search.Explanation.IDFExplanation;
 
 /** Similarity unit test.
  *
@@ -45,9 +46,18 @@
     public float queryNorm(float sumOfSquaredWeights) { return 1.0f; }
     public float tf(float freq) { return freq; }
     public float sloppyFreq(int distance) { return 2.0f; }
-    public float idf(Collection terms, Searcher searcher) { return 1.0f; }
     public float idf(int docFreq, int numDocs) { return 1.0f; }
     public float coord(int overlap, int maxOverlap) { return 1.0f; }
+    public IDFExplanation idfExplain(Collection terms, Searcher searcher) throws IOException
{
+      return new IDFExplanation() {
+        public float getIdf() {
+          return 1.0f;
+        }
+        public String explain() {
+          return "Inexplicable";
+        }
+      };
+    }
   }
 
   public void testSimilarity() throws Exception {
@@ -80,7 +90,7 @@
            this.scorer = scorer; 
          }
          public final void collect(int doc) throws IOException {
-           assertTrue(scorer.score() == 1.0f);
+           assertEquals(new Float(1.0f), new Float(scorer.score()));
          }
          public void setNextReader(IndexReader reader, int docBase) {}
          public boolean acceptsDocsOutOfOrder() {
@@ -100,7 +110,7 @@
          }
          public final void collect(int doc) throws IOException {
            //System.out.println("Doc=" + doc + " score=" + score);
-           assertTrue(scorer.score() == (float)doc+base+1);
+           assertEquals(new Float((float)doc+base+1), new Float(scorer.score()));
          }
          public void setNextReader(IndexReader reader, int docBase) {
            base = docBase;
@@ -114,8 +124,7 @@
     pq.add(a);
     pq.add(c);
     //System.out.println(pq.toString("field"));
-    searcher.search
-      (pq,
+    searcher.search(pq,
        new Collector() {
         private Scorer scorer;
         public void setScorer(Scorer scorer) throws IOException {
@@ -123,7 +132,7 @@
         }
          public final void collect(int doc) throws IOException {
            //System.out.println("Doc=" + doc + " score=" + score);
-           assertTrue(scorer.score() == 1.0f);
+           assertEquals(new Float(1.0f), new Float(scorer.score()));
          }
          public void setNextReader(IndexReader reader, int docBase) {}
          public boolean acceptsDocsOutOfOrder() {
@@ -140,7 +149,7 @@
         }
          public final void collect(int doc) throws IOException {
            //System.out.println("Doc=" + doc + " score=" + score);
-           assertTrue(scorer.score() == 2.0f);
+           assertEquals(new Float(2.0f), new Float(scorer.score()));
          }
          public void setNextReader(IndexReader reader, int docBase) {}
          public boolean acceptsDocsOutOfOrder() {

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestTermVectors.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestTermVectors.java?rev=829000&r1=828999&r2=829000&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestTermVectors.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestTermVectors.java
Fri Oct 23 11:23:04 2009
@@ -258,7 +258,7 @@
           //System.out.println("Doc Id: " + docId + " freq " + freq);
           TermFreqVector vector = knownSearcher.reader.getTermFreqVector(docId, "field");
           float tf = sim.tf(freq);
-          float idf = sim.idf(term, knownSearcher);
+          float idf = sim.idf(knownSearcher.docFreq(term), knownSearcher.maxDoc());
           //float qNorm = sim.queryNorm()
           //This is fine since we don't have stop words
           float lNorm = sim.lengthNorm("field", vector.getTerms().length);

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java?rev=829000&r1=828999&r2=829000&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
Fri Oct 23 11:23:04 2009
@@ -40,6 +40,7 @@
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.English;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.search.Explanation.IDFExplanation;
 
 
 public class TestPayloadNearQuery extends LuceneTestCase {
@@ -214,8 +215,17 @@
 			return 1;
 		}
 		// idf used for phrase queries
-		public float idf(Collection terms, Searcher searcher) {
-			return 1;
-		}
+    // idf used for phrase queries
+    public IDFExplanation idfExplain(Collection terms, Searcher searcher) throws IOException
{
+      return new IDFExplanation() {
+        public float getIdf() {
+          return 1.0f;
+        }
+
+        public String explain() {
+          return "Inexplicable";
+        }
+      };
+    }
 	}
 }



Mime
View raw message