lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dna...@apache.org
Subject svn commit: r373185 - in /lucene/java/trunk/contrib/spellchecker/src: java/org/apache/lucene/search/spell/SpellChecker.java test/org/apache/lucene/search/spell/TestSpellChecker.java
Date Sat, 28 Jan 2006 17:22:13 GMT
Author: dnaber
Date: Sat Jan 28 09:22:04 2006
New Revision: 373185

URL: http://svn.apache.org/viewcvs?rev=373185&view=rev
Log:
Don't suggest a word as similar for itself. Thanks to Michael Harhen for the fix.

Modified:
    lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
    lucene/java/trunk/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java

Modified: lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java?rev=373185&r1=373184&r2=373185&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
(original)
+++ lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
Sat Jan 28 09:22:04 2006
@@ -172,7 +172,7 @@
 
             sugword.string=hits.doc(i).get(F_WORD); // get orig word)
 
-            if (sugword.string==word) {
+            if (sugword.string.equals(word)) {
                 continue; // don't suggest a word for itself, that would be silly
             }
 

Modified: lucene/java/trunk/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java?rev=373185&r1=373184&r2=373185&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
(original)
+++ lucene/java/trunk/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
Sat Jan 28 09:22:04 2006
@@ -22,7 +22,7 @@
  */
 public class TestSpellChecker extends TestCase {
   private SpellChecker spellChecker;
-  Directory userindex, spellindex;
+  private Directory userindex, spellindex;
 
   protected void setUp() throws Exception {
     super.setUp();
@@ -61,18 +61,27 @@
 
       // test small word
       String[] similar = spellChecker.suggestSimilar("fvie", 2);
+      assertEquals(1, similar.length);
       assertEquals(similar[0], "five");
 
+      similar = spellChecker.suggestSimilar("five", 2);
+      assertEquals(1, similar.length);
+      assertEquals(similar[0], "nine");     // don't suggest a word for itself
+
       similar = spellChecker.suggestSimilar("fiv", 2);
+      assertEquals(1, similar.length);
       assertEquals(similar[0], "five");
 
       similar = spellChecker.suggestSimilar("ive", 2);
+      assertEquals(1, similar.length);
       assertEquals(similar[0], "five");
 
       similar = spellChecker.suggestSimilar("fives", 2);
+      assertEquals(1, similar.length);
       assertEquals(similar[0], "five");
 
       similar = spellChecker.suggestSimilar("fie", 2);
+      assertEquals(1, similar.length);
       assertEquals(similar[0], "five");
 
       similar = spellChecker.suggestSimilar("fi", 2);
@@ -88,7 +97,6 @@
       e.printStackTrace();
       fail();
     }
-
   }
 
 
@@ -96,14 +104,14 @@
     long time = System.currentTimeMillis();
     spellChecker.indexDictionary(new LuceneDictionary(r, field));
     time = System.currentTimeMillis() - time;
-    System.out.println("time to build " + field + ": " + time);
+    //System.out.println("time to build " + field + ": " + time);
   }
 
   private int numdoc() throws IOException {
     IndexReader rs = IndexReader.open(spellindex);
     int num = rs.numDocs();
     assertTrue(num != 0);
-    System.out.println("num docs: " + num);
+    //System.out.println("num docs: " + num);
     rs.close();
     return num;
   }



Mime
View raw message