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

svn commit: r686022 - in /lucene/solr/trunk/src/java/org/apache/solr/spelling: AbstractLuceneSpellChecker.java FileBasedSpellChecker.java IndexBasedSpellChecker.java QueryConverter.java SolrSpellChecker.java SpellingQueryConverter.java SpellingResult.java

Author: otis
Date: Thu Aug 14 13:27:55 2008
New Revision: 686022

URL: http://svn.apache.org/viewvc?rev=686022&view=rev
Log:
SOLR-474 - Spellchecker javadoc improvements

Modified:
    lucene/solr/trunk/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
    lucene/solr/trunk/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java
    lucene/solr/trunk/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java
    lucene/solr/trunk/src/java/org/apache/solr/spelling/QueryConverter.java
    lucene/solr/trunk/src/java/org/apache/solr/spelling/SolrSpellChecker.java
    lucene/solr/trunk/src/java/org/apache/solr/spelling/SpellingQueryConverter.java
    lucene/solr/trunk/src/java/org/apache/solr/spelling/SpellingResult.java

Modified: lucene/solr/trunk/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java?rev=686022&r1=686021&r2=686022&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java Thu Aug 14 13:27:55 2008
@@ -24,10 +24,11 @@
 
 
 /**
- * Abstract base class for all Lucene based spell checking implementations.
+ * Abstract base class for all Lucene-based spell checking implementations.
  * 
  * <p>
- * Refer to http://wiki.apache.org/solr/SpellCheckComponent for more details
+ * Refer to <a href="http://wiki.apache.org/solr/SpellCheckComponent">SpellCheckComponent</a>
+ * for more details.
  * </p>
  * 
  * @since solr 1.3

Modified: lucene/solr/trunk/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java?rev=686022&r1=686021&r2=686022&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/spelling/FileBasedSpellChecker.java Thu Aug 14 13:27:55 2008
@@ -40,8 +40,7 @@
 
 /**
  * <p>
- * A spell checker implementation which can load words from a text 
- * file (one word per line).
+ * A spell checker implementation that loads words from a text file (one word per line).
  * </p>
  *
  * @since solr 1.3

Modified: lucene/solr/trunk/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java?rev=686022&r1=686021&r2=686022&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/spelling/IndexBasedSpellChecker.java Thu Aug 14 13:27:55 2008
@@ -33,11 +33,12 @@
 
 /**
  * <p>
- * A spell checker implementation which can load words from Solr as well as arbitary Lucene indices.
+ * A spell checker implementation that loads words from Solr as well as arbitary Lucene indices.
  * </p>
  * 
  * <p>
- * Refer to http://wiki.apache.org/solr/SpellCheckComponent for more details
+ * Refer to <a href="http://wiki.apache.org/solr/SpellCheckComponent">SpellCheckComponent</a>
+ * for more details.
  * </p>
  * 
  * @since solr 1.3
@@ -109,7 +110,6 @@
     initSourceReader();
   }
 
-
   public float getThreshold() {
     return threshold;
   }

Modified: lucene/solr/trunk/src/java/org/apache/solr/spelling/QueryConverter.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/spelling/QueryConverter.java?rev=686022&r1=686021&r2=686022&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/spelling/QueryConverter.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/spelling/QueryConverter.java Thu Aug 14 13:27:55 2008
@@ -17,14 +17,15 @@
  * <p>
  * It is only invoked for the CommonParams.Q parameter, and <b>not</b> the
  * "spellcheck.q" parameter. Systems that use their own query parser or those
- * that find issue with the basic implementation will want to implement their
+ * that find issue with the basic implementation should implement their
  * own QueryConverter instead of using the provided implementation
  * (SpellingQueryConverter) by overriding the appropriate methods on the
  * SpellingQueryConverter and registering it in the solrconfig.xml
  * </p>
  * 
  * <p>
- * Refer to http://wiki.apache.org/solr/SpellCheckComponent for more details
+ * Refer to <a href="http://wiki.apache.org/solr/SpellCheckComponent">SpellCheckComponent</a>
+ * for more details
  * </p>
  * 
  * @since solr 1.3

Modified: lucene/solr/trunk/src/java/org/apache/solr/spelling/SolrSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/spelling/SolrSpellChecker.java?rev=686022&r1=686021&r2=686022&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/spelling/SolrSpellChecker.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/spelling/SolrSpellChecker.java Thu Aug 14 13:27:55 2008
@@ -29,7 +29,8 @@
 
 /**
  * <p>
- * Refer to http://wiki.apache.org/solr/SpellCheckComponent for more details
+ * Refer to <a href="http://wiki.apache.org/solr/SpellCheckComponent">SpellCheckComponent</a>
+ * for more details.
  * </p>
  * 
  * @since solr 1.3
@@ -37,10 +38,11 @@
 public abstract class SolrSpellChecker {
   public static final String DICTIONARY_NAME = "name";
   public static final String DEFAULT_DICTIONARY_NAME = "default";
+  /** Dictionary name */
   protected String name;
   protected Analyzer analyzer;
 
-  public String init(NamedList config, SolrCore core){
+  public String init(NamedList config, SolrCore core) {
     name = (String) config.get(DICTIONARY_NAME);
     if (name == null) {
       name = DEFAULT_DICTIONARY_NAME;
@@ -48,25 +50,23 @@
     return name;
   }
   
-  public Analyzer getQueryAnalyzer()    {
+  public Analyzer getQueryAnalyzer() {
     return analyzer;
   }
 
-
   public String getDictionaryName() {
     return name;
   }
 
-
   /**
-   * Reload the index.  Useful if an external process is responsible for building the spell checker.
+   * Reloads the index.  Useful if an external process is responsible for building the spell checker.
    *
    * @throws java.io.IOException
    */
   public abstract void reload() throws IOException;
 
   /**
-   * (re)Build The Spelling index.  May be a NOOP if the implementation doesn't require building, or can't be rebuilt
+   * (re)Builds the spelling index.  May be a NOOP if the implementation doesn't require building, or can't be rebuilt.
    */
   public abstract void build(SolrCore core, SolrIndexSearcher searcher);
 
@@ -99,8 +99,8 @@
   }
 
   /**
-   * Get suggestions for the given query.  Tokenizes the query using a field appropriate Analyzer.  The {@link SpellingResult#getSuggestions()} suggestions must be ordered by 
-   * best suggestion first
+   * Get suggestions for the given query.  Tokenizes the query using a field appropriate Analyzer.
+   * The {@link SpellingResult#getSuggestions()} suggestions must be ordered by best suggestion first.
    *
    * @param tokens          The Tokens to be spell checked.
    * @param reader          The (optional) IndexReader.  If there is not IndexReader, than extendedResults are not possible

Modified: lucene/solr/trunk/src/java/org/apache/solr/spelling/SpellingQueryConverter.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/spelling/SpellingQueryConverter.java?rev=686022&r1=686021&r2=686022&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/spelling/SpellingQueryConverter.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/spelling/SpellingQueryConverter.java Thu Aug 14 13:27:55 2008
@@ -30,6 +30,8 @@
 
 
 /**
+ * Converts the query string to a Collection of Lucene tokens using a regular expression.
+ * Boolean operators AND and OR are skipped.
  *
  * @since solr 1.3
  **/
@@ -37,9 +39,13 @@
 
   protected Pattern QUERY_REGEX = Pattern.compile("(?:(?!(\\w+:|\\d+)))\\w+");
 
-
+  /**
+   * Converts the original query string to a collection of Lucene Tokens.
+   * @param original the original query string
+   * @return a Collection of Lucene Tokens
+   */
   public Collection<Token> convert(String original) {
-    if( original == null ) { // this can happen with q.alt = and no query
+    if (original == null) { // this can happen with q.alt = and no query
       return Collections.emptyList();
     }
     Collection<Token> result = new ArrayList<Token>();

Modified: lucene/solr/trunk/src/java/org/apache/solr/spelling/SpellingResult.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/spelling/SpellingResult.java?rev=686022&r1=686021&r2=686022&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/spelling/SpellingResult.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/spelling/SpellingResult.java Thu Aug 14 13:27:55 2008
@@ -10,7 +10,7 @@
 
 /**
  * Implementations of SolrSpellChecker must return suggestions as SpellResult instance.
- * This is converted into the required NamedList format in SpellCheckComponent
+ * This is converted into the required NamedList format in SpellCheckComponent.
  * 
  * @since solr 1.3
  */
@@ -34,7 +34,7 @@
   }
 
   /**
-   * Add a whole bunch of suggestions, and don't worry about frequency
+   * Adds a whole bunch of suggestions, and does not worry about frequency.
    *
    * @param token The token to associate the suggestions with
    * @param suggestions The suggestions
@@ -58,7 +58,7 @@
   }
 
   /**
-   * Suggestions must be added with the best suggestion first.  ORDER is important
+   * Suggestions must be added with the best suggestion first.  ORDER is important.
    * @param token The {@link org.apache.lucene.analysis.Token}
    * @param suggestion The suggestion for the Token
    * @param docFreq The document frequency
@@ -74,7 +74,7 @@
   }
 
   /**
-   * Get the suggestions for the given token
+   * Gets the suggestions for the given token.
    *
    * @param token The {@link org.apache.lucene.analysis.Token} to look up
    * @return A LinkedHashMap of the suggestions.  Key is the suggestion, value is the token frequency in the index, else {@link #NO_FREQUENCY_INFO}.