Class SuggestionsOrdererFeatureExtractor
- java.lang.Object
-
- org.languagetool.rules.spelling.suggestions.SuggestionsOrdererFeatureExtractor
-
- All Implemented Interfaces:
SuggestionsOrderer
- Direct Known Subclasses:
XGBoostSuggestionsOrderer
public class SuggestionsOrdererFeatureExtractor extends Object implements SuggestionsOrderer
Computes features that can be stored for training a model to rank suggestions, or when using the same model for prediction Used directly by SuggestionChangesTest for the former, and as a superclass for the latter
-
-
Field Summary
Fields Modifier and Type Field Description protected Language
language
protected LanguageModel
languageModel
protected double
mistakeProb
protected String
score
protected int
topN
-
Constructor Summary
Constructors Constructor Description SuggestionsOrdererFeatureExtractor(Language lang, LanguageModel languageModel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.commons.lang3.tuple.Pair<List<SuggestedReplacement>,SortedMap<String,Float>>
computeFeatures(List<String> suggestions, String word, AnalyzedSentence sentence, int startPos)
compute features for training or prediction of a ranking model for suggestionsprotected void
initParameters()
boolean
isMlAvailable()
List<SuggestedReplacement>
orderSuggestions(List<String> suggestions, String word, AnalyzedSentence sentence, int startPos)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.languagetool.rules.spelling.suggestions.SuggestionsOrderer
orderSuggestionsUsingModel
-
-
-
-
Field Detail
-
language
protected final Language language
-
languageModel
protected final LanguageModel languageModel
-
topN
protected int topN
-
score
protected String score
-
mistakeProb
protected double mistakeProb
-
-
Constructor Detail
-
SuggestionsOrdererFeatureExtractor
public SuggestionsOrdererFeatureExtractor(Language lang, LanguageModel languageModel)
-
-
Method Detail
-
initParameters
protected void initParameters()
-
isMlAvailable
public boolean isMlAvailable()
- Specified by:
isMlAvailable
in interfaceSuggestionsOrderer
-
orderSuggestions
public List<SuggestedReplacement> orderSuggestions(List<String> suggestions, String word, AnalyzedSentence sentence, int startPos)
- Specified by:
orderSuggestions
in interfaceSuggestionsOrderer
-
computeFeatures
public org.apache.commons.lang3.tuple.Pair<List<SuggestedReplacement>,SortedMap<String,Float>> computeFeatures(List<String> suggestions, String word, AnalyzedSentence sentence, int startPos)
compute features for training or prediction of a ranking model for suggestions- Parameters:
suggestions
-word
-sentence
-startPos
-- Returns:
- correction candidates, features for the match in general, features specific to candidates
-
-