lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o...@apache.org
Subject svn commit: r468580 - /lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
Date Fri, 27 Oct 2006 23:00:37 GMT
Author: otis
Date: Fri Oct 27 16:00:36 2006
New Revision: 468580

URL: http://svn.apache.org/viewvc?view=rev&rev=468580
Log:
- Create the index if it doesn't exist; CamelCased spellindex var

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

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?view=diff&rev=468580&r1=468579&r2=468580
==============================================================================
--- 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
Fri Oct 27 16:00:36 2006
@@ -63,7 +63,7 @@
   /**
    * the spell index
    */
-  Directory spellindex;
+  Directory spellIndex;
 
   /**
    * Boost value for start and end grams
@@ -81,9 +81,13 @@
     this.setSpellIndex(spellIndex);
   }
 
-  public void setSpellIndex(Directory spellindex) throws IOException {
-    this.spellindex = spellindex;
-    searcher = new IndexSearcher(this.spellindex);
+  public void setSpellIndex(Directory spellIndex) throws IOException {
+    this.spellIndex = spellIndex;
+    if (!IndexReader.indexExists(spellIndex)) {
+        IndexWriter writer = new IndexWriter(spellIndex, null, true);
+        writer.close();
+    }
+    searcher = new IndexSearcher(this.spellIndex);
   }
 
   /**
@@ -238,8 +242,8 @@
   }
 
   public void clearIndex() throws IOException {
-    IndexReader.unlock(spellindex);
-    IndexWriter writer = new IndexWriter(spellindex, null, true);
+    IndexReader.unlock(spellIndex);
+    IndexWriter writer = new IndexWriter(spellIndex, null, true);
     writer.close();
   }
 
@@ -251,7 +255,7 @@
    */
   public boolean exist(String word) throws IOException {
     if (reader == null) {
-      reader = IndexReader.open(spellindex);
+      reader = IndexReader.open(spellIndex);
     }
     return reader.docFreq(new Term(F_WORD, word)) > 0;
   }
@@ -262,9 +266,9 @@
    * @throws IOException
    */
   public void indexDictionary(Dictionary dict) throws IOException {
-    IndexReader.unlock(spellindex);
-    IndexWriter writer = new IndexWriter(spellindex, new WhitespaceAnalyzer(),
-        !IndexReader.indexExists(spellindex));
+    IndexReader.unlock(spellIndex);
+    IndexWriter writer = new IndexWriter(spellIndex, new WhitespaceAnalyzer(),
+        !IndexReader.indexExists(spellIndex));
     writer.setMergeFactor(300);
     writer.setMaxBufferedDocs(150);
 



Mime
View raw message