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:47:27 UTC
svn commit: r415097 -
/lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.java
Author: otis
Date: Sat Jun 17 22:47:26 2006
New Revision: 415097
URL: http://svn.apache.org/viewvc?rev=415097&view=rev
Log:
- LUCENE-593 partial fix (field name interned)
- Made vars and LuceneIterator ctor private
- Fixed comments
Modified:
lucene/java/trunk/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.java
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=415097&r1=415096&r2=415097&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:47:26 2006
@@ -31,12 +31,12 @@
* @author Nicolas Maisonneuve
*/
public class LuceneDictionary implements Dictionary {
- IndexReader reader;
- String field;
+ private IndexReader reader;
+ private String field;
public LuceneDictionary(IndexReader reader, String field) {
this.reader = reader;
- this.field = field;
+ this.field = field.intern();
}
public final Iterator getWordsIterator() {
@@ -49,15 +49,14 @@
private Term actualTerm;
private boolean hasNextCalled;
- public LuceneIterator() {
+ LuceneIterator() {
try {
termEnum = reader.terms(new Term(field, ""));
- } catch (IOException ex) {
- ex.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
}
}
-
public Object next() {
if (!hasNextCalled) {
hasNext();
@@ -66,30 +65,28 @@
return (actualTerm != null) ? actualTerm.text() : null;
}
-
public boolean hasNext() {
hasNextCalled = true;
try {
- // if there is still words
+ // if there are no more words
if (!termEnum.next()) {
actualTerm = null;
return false;
}
- // if the next word are in the field
+ // if the next word is in the field
actualTerm = termEnum.term();
- String fieldt = actualTerm.field();
- if (fieldt != field) {
+ String currentField = actualTerm.field();
+ if (currentField != field) {
actualTerm = null;
return false;
}
return true;
- } catch (IOException ex) {
- ex.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
return false;
}
}
- public void remove() {
- }
+ public void remove() {}
}
}