You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2011/09/16 16:05:46 UTC
svn commit: r1171570 - in /lucene/dev/trunk:
modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java
solr/core/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
Author: rmuir
Date: Fri Sep 16 14:05:46 2011
New Revision: 1171570
URL: http://svn.apache.org/viewvc?rev=1171570&view=rev
Log:
LUCENE-3436: remove deprecations from trunk / dont use deprecated methods
Modified:
lucene/dev/trunk/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
Modified: lucene/dev/trunk/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java?rev=1171570&r1=1171569&r2=1171570&view=diff
==============================================================================
--- lucene/dev/trunk/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java (original)
+++ lucene/dev/trunk/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java Fri Sep 16 14:05:46 2011
@@ -275,89 +275,6 @@ public class SpellChecker implements jav
}
/**
- * Suggest similar words (optionally restricted to a field of an index).
- *
- * <p>As the Lucene similarity that is used to fetch the most relevant n-grammed terms
- * is not the same as the edit distance strategy used to calculate the best
- * matching spell-checked word from the hits that Lucene found, one usually has
- * to retrieve a couple of numSug's in order to get the true best match.
- *
- * <p>I.e. if numSug == 1, don't count on that suggestion being the best one.
- * Thus, you should set this value to <b>at least</b> 5 for a good suggestion.
- *
- * <p>Uses the {@link #getAccuracy()} value passed into the constructor as the accuracy.
- *
- * @param word the word you want a spell check done on
- * @param numSug the number of suggested words
- * @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 as frequent or more frequent than the searched word
- * (only if restricted mode = (indexReader!=null and field!=null)
- * @throws IOException if the underlying index throws an {@link IOException}
- * @throws AlreadyClosedException if the Spellchecker is already closed
- * @return String[] the sorted list of the suggest words with these 2 criteria:
- * first criteria: the edit distance, second criteria (only if restricted mode): the popularity
- * of the suggest words in the field of the user index
- *
- * @see #suggestSimilar(String, int, IndexReader, String, SuggestMode, float)
- *
- * @deprecated
- * use suggestSimilar(String, int, IndexReader, String, SuggestMode)
- * <ul>
- * <li>SuggestMode.SUGGEST_WHEN_NOT_IN_INDEX instead of morePopular=false</li>
- * <li>SuggestMode.SuGGEST_MORE_POPULAR instead of morePopular=true</li>
- * </ul>
- */
- @Deprecated
- public String[] suggestSimilar(String word, int numSug, IndexReader ir,
- String field, boolean morePopular) throws IOException {
- return suggestSimilar(word, numSug, ir, field, morePopular, accuracy);
- }
-
-
- /**
- * Suggest similar words (optionally restricted to a field of an index).
- *
- * <p>As the Lucene similarity that is used to fetch the most relevant n-grammed terms
- * is not the same as the edit distance strategy used to calculate the best
- * matching spell-checked word from the hits that Lucene found, one usually has
- * to retrieve a couple of numSug's in order to get the true best match.
- *
- * <p>I.e. if numSug == 1, don't count on that suggestion being the best one.
- * Thus, you should set this value to <b>at least</b> 5 for a good suggestion.
- *
- * @param word the word you want a spell check done on
- * @param numSug the number of suggested words
- * @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 as frequent or more frequent than the searched word
- * (only if restricted mode = (indexReader!=null and field!=null)
- * @param accuracy The minimum score a suggestion must have in order to qualify for inclusion in the results
- * @throws IOException if the underlying index throws an {@link IOException}
- * @throws AlreadyClosedException if the Spellchecker is already closed
- * @return String[] the sorted list of the suggest words with these 2 criteria:
- * first criteria: the edit distance, second criteria (only if restricted mode): the popularity
- * of the suggest words in the field of the user index
- *
- * @see #suggestSimilar(String, int, IndexReader, String, SuggestMode, float)
- *
- * @deprecated
- * use suggestSimilar(String, int, IndexReader, String, SuggestMode, float)
- * <ul>
- * <li>SuggestMode.SUGGEST_WHEN_NOT_IN_INDEX instead of morePopular=false</li>
- * <li>SuggestMode.SuGGEST_MORE_POPULAR instead of morePopular=true</li>
- * </ul>
- */
- @Deprecated
- public String[] suggestSimilar(String word, int numSug, IndexReader ir,
- String field, boolean morePopular, float accuracy) throws IOException {
- return suggestSimilar(word, numSug, ir, field, morePopular ? SuggestMode.SUGGEST_MORE_POPULAR :
- SuggestMode.SUGGEST_WHEN_NOT_IN_INDEX, accuracy);
- }
-
- /**
* Calls {@link #suggestSimilar(String, int, IndexReader, String, SuggestMode, float)
* suggestSimilar(word, numSug, ir, suggestMode, field, this.accuracy)}
*
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java?rev=1171570&r1=1171569&r2=1171570&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java Fri Sep 16 14:05:46 2011
@@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import org.apache.lucene.search.spell.SuggestMode;
import org.apache.lucene.search.spell.SuggestWord;
import org.apache.lucene.search.spell.SuggestWordFrequencyComparator;
import org.apache.lucene.search.spell.SuggestWordQueue;
@@ -168,13 +169,14 @@ public abstract class AbstractLuceneSpel
float theAccuracy = (options.accuracy == Float.MIN_VALUE) ? spellChecker.getAccuracy() : options.accuracy;
int count = Math.max(options.count, AbstractLuceneSpellChecker.DEFAULT_SUGGESTION_COUNT);
+ SuggestMode mode = options.onlyMorePopular ? SuggestMode.SUGGEST_MORE_POPULAR : SuggestMode.SUGGEST_WHEN_NOT_IN_INDEX;
for (Token token : options.tokens) {
String tokenText = new String(token.buffer(), 0, token.length());
String[] suggestions = spellChecker.suggestSimilar(tokenText,
count,
field != null ? reader : null, //workaround LUCENE-1295
field,
- options.onlyMorePopular, theAccuracy);
+ mode, theAccuracy);
if (suggestions.length == 1 && suggestions[0].equals(tokenText)) {
//These are spelled the same, continue on
continue;