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 2006/06/18 07:32:55 UTC

svn commit: r415093 - in /lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell: Dictionary.java LuceneDictionary.java PlainTextDictionary.java SpellChecker.java SuggestWord.java SuggestWordQueue.java

Author: otis
Date: Sat Jun 17 22:32:54 2006
New Revision: 415093

URL: http://svn.apache.org/viewvc?rev=415093&view=rev
Log:
- Cosmetics

Modified:
    lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/Dictionary.java
    lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.java
    lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/PlainTextDictionary.java
    lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
    lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SuggestWord.java
    lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SuggestWordQueue.java

Modified: lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/Dictionary.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/Dictionary.java?rev=415093&r1=415092&r2=415093&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/Dictionary.java (original)
+++ lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/Dictionary.java Sat Jun 17 22:32:54 2006
@@ -24,10 +24,9 @@
  */
 public interface Dictionary {
 
-    /**
-     * return all the words present in the dictionnary
-     * @return Iterator
-     */
-    public Iterator getWordsIterator();
-
+  /**
+   * Return all words present in the dictionary
+   * @return Iterator
+   */
+  Iterator getWordsIterator();
 }

Modified: lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.java?rev=415093&r1=415092&r2=415093&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.java (original)
+++ lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.java Sat Jun 17 22:32:54 2006
@@ -47,7 +47,7 @@
   final class LuceneIterator implements Iterator {
     private TermEnum termEnum;
     private Term actualTerm;
-    private boolean has_next_called;
+    private boolean hasNextCalled;
 
     public LuceneIterator() {
       try {
@@ -59,16 +59,16 @@
 
 
     public Object next() {
-      if (!has_next_called) {
+      if (!hasNextCalled) {
         hasNext();
       }
-      has_next_called = false;
+      hasNextCalled = false;
       return (actualTerm != null) ? actualTerm.text() : null;
     }
 
 
     public boolean hasNext() {
-      has_next_called = true;
+      hasNextCalled = true;
       try {
         // if there is still words
         if (!termEnum.next()) {
@@ -90,6 +90,6 @@
     }
 
     public void remove() {
-    };
+    }
   }
 }

Modified: lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/PlainTextDictionary.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/PlainTextDictionary.java?rev=415093&r1=415092&r2=415093&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/PlainTextDictionary.java (original)
+++ lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/PlainTextDictionary.java Sat Jun 17 22:32:54 2006
@@ -27,10 +27,10 @@
 /**
  * Dictionary represented by a file text.
  * 
- * <p>Format allowed: 1 word per line:<br>
- * word1<br>
- * word2<br>
- * word3<br>
+ * <p/>Format allowed: 1 word per line:<br/>
+ * word1<br/>
+ * word2<br/>
+ * word3<br/>
  *
  * @author Nicolas Maisonneuve
  */
@@ -38,7 +38,7 @@
 
   private BufferedReader in;
   private String line;
-  private boolean has_next_called;
+  private boolean hasNextCalled;
 
   public PlainTextDictionary(File file) throws FileNotFoundException {
     in = new BufferedReader(new FileReader(file));
@@ -55,16 +55,16 @@
 
   final class fileIterator implements Iterator {
     public Object next() {
-      if (!has_next_called) {
+      if (!hasNextCalled) {
         hasNext();
       }
-      has_next_called = false;
+      hasNextCalled = false;
       return line;
     }
 
 
     public boolean hasNext() {
-      has_next_called = true;
+      hasNextCalled = true;
       try {
         line = in.readLine();
       } catch (IOException ex) {
@@ -77,7 +77,7 @@
 
 
     public void remove() {
-    };
+    }
   }
 
 }

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=415093&r1=415092&r2=415093&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 Jun 17 22:32:54 2006
@@ -38,8 +38,8 @@
 
 /**
  *  <p>
- *	Spell Checker class  (Main class) <br/>
- * (initially inspired by the David Spencer code).
+ *   Spell Checker class  (Main class) <br/>
+ *   (initially inspired by the David Spencer code).
  *  </p>
  *  
  *  <p>Example Usage:
@@ -351,7 +351,7 @@
     }
 
 
-    protected void finalize () throws Throwable {
+    protected void finalize() throws Throwable {
         if (reader!=null) {
             reader.close();
         }

Modified: lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SuggestWord.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SuggestWord.java?rev=415093&r1=415092&r2=415093&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SuggestWord.java (original)
+++ lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SuggestWord.java Sat Jun 17 22:32:54 2006
@@ -18,47 +18,43 @@
  */
 
 /**
- *  SuggestWord Class, used in suggestSimilar method in SpellChecker class.
+ *  SuggestWord, used in suggestSimilar method in SpellChecker class.
  * 
  *  @author Nicolas Maisonneuve
  */
- final class SuggestWord {
-    /**
-     * the score of the word
-     */
-    public float score;
-
-
-    /**
-     * The freq of the word
-     */
-    public int freq;
-
-
-    /**
-     * the suggested word
-     */
-    public String string;
-
-
-    public final int compareTo (SuggestWord a) {
-        //first criteria: the edit distance
-        if (score>a.score) {
-            return 1;
-        }
-        if (score<a.score) {
-            return-1;
-        }
-
-        //second criteria (if first criteria is equal): the popularity
-        if (freq>a.freq) {
-            return 1;
-        }
+final class SuggestWord {
+  /**
+   * the score of the word
+   */
+  public float score;
+
+  /**
+   * The freq of the word
+   */
+  public int freq;
+
+  /**
+   * the suggested word
+   */
+  public String string;
+
+  public final int compareTo (SuggestWord a) {
+    //first criteria: the edit distance
+    if (score > a.score) {
+      return 1;
+    }
+    if (score < a.score) {
+      return -1;
+    }
 
-        if (freq<a.freq) {
-            return-1;
-        }
+    //second criteria (if first criteria is equal): the popularity
+    if (freq > a.freq) {
+      return 1;
+    }
 
-        return 0;
+    if (freq < a.freq) {
+      return -1;
     }
+    return 0;
+  }
 }

Modified: lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SuggestWordQueue.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SuggestWordQueue.java?rev=415093&r1=415092&r2=415093&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SuggestWordQueue.java (original)
+++ lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SuggestWordQueue.java Sat Jun 17 22:32:54 2006
@@ -17,25 +17,23 @@
  * limitations under the License.
  */
 
-/**
- *  to sort SuggestWord
- * @author Nicolas Maisonneuve
- */
 import org.apache.lucene.util.PriorityQueue;
 
 
-final class SuggestWordQueue
-extends PriorityQueue {
-
-    SuggestWordQueue (int size) {
-        initialize(size);
-    }
+/**
+ * Sorts SuggestWord instances
+ * @author Nicolas Maisonneuve
+ */
+final class SuggestWordQueue extends PriorityQueue {
 
-    protected final boolean lessThan (Object a, Object b) {
-        SuggestWord wa=(SuggestWord) a;
-        SuggestWord wb=(SuggestWord) b;
-        int val=wa.compareTo(wb);
-        return val<0;
-    }
+  SuggestWordQueue (int size) {
+    initialize(size);
+  }
 
+  protected final boolean lessThan (Object a, Object b) {
+    SuggestWord wa = (SuggestWord) a;
+    SuggestWord wb = (SuggestWord) b;
+    int val = wa.compareTo(wb);
+    return val < 0;
+  }
 }