mirror of https://github.com/apache/lucene.git
LUCENE-3436: remove deprecations from trunk / dont use deprecated methods
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1171570 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c0965ed3a2
commit
28ae5a5763
|
@ -274,89 +274,6 @@ public class SpellChecker implements java.io.Closeable {
|
||||||
return this.suggestSimilar(word, numSug, null, null, SuggestMode.SUGGEST_WHEN_NOT_IN_INDEX, accuracy);
|
return this.suggestSimilar(word, numSug, null, null, SuggestMode.SUGGEST_WHEN_NOT_IN_INDEX, 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.
|
|
||||||
*
|
|
||||||
* <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)
|
* Calls {@link #suggestSimilar(String, int, IndexReader, String, SuggestMode, float)
|
||||||
* suggestSimilar(word, numSug, ir, suggestMode, field, this.accuracy)}
|
* suggestSimilar(word, numSug, ir, suggestMode, field, this.accuracy)}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.lucene.search.spell.SuggestMode;
|
||||||
import org.apache.lucene.search.spell.SuggestWord;
|
import org.apache.lucene.search.spell.SuggestWord;
|
||||||
import org.apache.lucene.search.spell.SuggestWordFrequencyComparator;
|
import org.apache.lucene.search.spell.SuggestWordFrequencyComparator;
|
||||||
import org.apache.lucene.search.spell.SuggestWordQueue;
|
import org.apache.lucene.search.spell.SuggestWordQueue;
|
||||||
|
@ -168,13 +169,14 @@ public abstract class AbstractLuceneSpellChecker extends SolrSpellChecker {
|
||||||
float theAccuracy = (options.accuracy == Float.MIN_VALUE) ? spellChecker.getAccuracy() : options.accuracy;
|
float theAccuracy = (options.accuracy == Float.MIN_VALUE) ? spellChecker.getAccuracy() : options.accuracy;
|
||||||
|
|
||||||
int count = Math.max(options.count, AbstractLuceneSpellChecker.DEFAULT_SUGGESTION_COUNT);
|
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) {
|
for (Token token : options.tokens) {
|
||||||
String tokenText = new String(token.buffer(), 0, token.length());
|
String tokenText = new String(token.buffer(), 0, token.length());
|
||||||
String[] suggestions = spellChecker.suggestSimilar(tokenText,
|
String[] suggestions = spellChecker.suggestSimilar(tokenText,
|
||||||
count,
|
count,
|
||||||
field != null ? reader : null, //workaround LUCENE-1295
|
field != null ? reader : null, //workaround LUCENE-1295
|
||||||
field,
|
field,
|
||||||
options.onlyMorePopular, theAccuracy);
|
mode, theAccuracy);
|
||||||
if (suggestions.length == 1 && suggestions[0].equals(tokenText)) {
|
if (suggestions.length == 1 && suggestions[0].equals(tokenText)) {
|
||||||
//These are spelled the same, continue on
|
//These are spelled the same, continue on
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue