Package org.apache.solr.spelling
Class SpellingResult
- java.lang.Object
-
- org.apache.solr.spelling.SpellingResult
-
public class SpellingResult extends Object
Implementations of SolrSpellChecker must return suggestions as SpellResult instance. This is converted into the required NamedList format in SpellCheckComponent.- Since:
- solr 1.3
-
-
Field Summary
Fields Modifier and Type Field Description static intNO_FREQUENCY_INFO
-
Constructor Summary
Constructors Constructor Description SpellingResult()SpellingResult(Collection<Token> tokens)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Token token, String suggestion, int docFreq)Suggestions must be added with the best suggestion first.voidadd(Token token, List<String> suggestions)Adds a whole bunch of suggestions, and does not worry about frequency.voidaddFrequency(Token token, int docFreq)Adds an original token with its document frequencyLinkedHashMap<String,Integer>get(Token token)Gets the suggestions for the given token.Map<Token,LinkedHashMap<String,Integer>>getSuggestions()All the suggestions.Map<Token,Integer>getTokenFrequency()IntegergetTokenFrequency(Token token)The token frequency of the input token in the collectionCollection<Token>getTokens()booleanhasTokenFrequencyInfo()voidsetTokens(Collection<Token> tokens)
-
-
-
Field Detail
-
NO_FREQUENCY_INFO
public static final int NO_FREQUENCY_INFO
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SpellingResult
public SpellingResult()
-
SpellingResult
public SpellingResult(Collection<Token> tokens)
-
-
Method Detail
-
add
public void add(Token token, List<String> suggestions)
Adds a whole bunch of suggestions, and does not worry about frequency.- Parameters:
token- The token to associate the suggestions withsuggestions- The suggestions
-
addFrequency
public void addFrequency(Token token, int docFreq)
Adds an original token with its document frequency- Parameters:
token- original tokendocFreq- original token's document frequency
-
add
public void add(Token token, String suggestion, int docFreq)
Suggestions must be added with the best suggestion first. ORDER is important.- Parameters:
token- TheTokensuggestion- The suggestion for the TokendocFreq- The document frequency
-
get
public LinkedHashMap<String,Integer> get(Token token)
Gets the suggestions for the given token.- Parameters:
token- TheTokento look up- Returns:
- A LinkedHashMap of the suggestions. Key is the suggestion, value is the token frequency
in the index, else
NO_FREQUENCY_INFO.The suggestions are added in sorted order (i.e. best suggestion first) then the iterator will return the suggestions in order
-
getTokenFrequency
public Integer getTokenFrequency(Token token)
The token frequency of the input token in the collection- Parameters:
token- The token- Returns:
- The frequency or null
-
hasTokenFrequencyInfo
public boolean hasTokenFrequencyInfo()
-
getSuggestions
public Map<Token,LinkedHashMap<String,Integer>> getSuggestions()
All the suggestions. The ordering of the inner LinkedHashMap is by best suggestion first.- Returns:
- The Map of suggestions for each Token. Key is the token, value is a LinkedHashMap whose
key is the Suggestion and the value is the frequency or
NO_FREQUENCY_INFOif frequency info is not available.
-
getTokens
public Collection<Token> getTokens()
- Returns:
- The original tokens
-
setTokens
public void setTokens(Collection<Token> tokens)
-
-