You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by ot...@apache.org on 2008/05/22 08:34:19 UTC

svn commit: r659019 - in /lucene/java/trunk: CHANGES.txt contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java

Author: otis
Date: Wed May 21 23:34:18 2008
New Revision: 659019

URL: http://svn.apache.org/viewvc?rev=659019&view=rev
Log:
LUCENE-1046: Removed dead code in SpellChecker

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=659019&r1=659018&r2=659019&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Wed May 21 23:34:18 2008
@@ -99,6 +99,9 @@
     methods, plus removal of IndexReader reference.
     (Naveen Belkale via Otis Gospodnetic)
 
+10. LUCENE-1046: Removed dead code in SpellChecker
+    (Daniel Naber via Otis Gospodnetic)
+
 New features
 
  1. LUCENE-1137: Added Token.set/getFlags() accessors for passing more information about a Token through the analysis

Modified: lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java?rev=659019&r1=659018&r2=659019&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 Wed May 21 23:34:18 2008
@@ -152,7 +152,7 @@
    * @param ir the indexReader of the user index (can be null see field param)
    * @param field the field of the user index: if field is not null, the suggested
    * words are restricted to the words present in this field.
-   * @param morePopular return only the suggest words that are more frequent than the searched word
+   * @param morePopular return only the suggest words that are as frequent or more frequent than the searched word
    * (only if restricted mode = (indexReader!=null and field!=null)
    * @throws IOException
    * @return String[] the sorted list of the suggest words with these 2 criteria:
@@ -166,9 +166,10 @@
     final TRStringDistance sd = new TRStringDistance(word);
     final int lengthWord = word.length();
 
-    final int goalFreq = (morePopular && ir != null) ? ir.docFreq(new Term(field, word)) : 0;
+    final int freq = (ir != null && field != null) ? ir.docFreq(new Term(field, word)) : 0;
+    final int goalFreq = (morePopular && ir != null && field != null) ? freq : 0;
     // if the word exists in the real index and we don't care for word frequency, return the word itself
-    if (!morePopular && goalFreq > 0) {
+    if (!morePopular && freq > 0) {
       return new String[] { word };
     }