Class SuggestionsOrdererFeatureExtractor
java.lang.Object
org.languagetool.rules.spelling.suggestions.SuggestionsOrdererFeatureExtractor
- All Implemented Interfaces:
SuggestionsOrderer
- Direct Known Subclasses:
XGBoostSuggestionsOrderer
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Language
protected final LanguageModel
private static final org.slf4j.Logger
protected double
protected String
protected int
-
Constructor Summary
ConstructorsConstructorDescriptionSuggestionsOrdererFeatureExtractor
(Language lang, LanguageModel languageModel) -
Method Summary
Modifier and TypeMethodDescriptionorg.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
boolean
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 Details
-
logger
private static final org.slf4j.Logger logger -
language
-
languageModel
-
topN
protected int topN -
score
-
mistakeProb
protected double mistakeProb
-
-
Constructor Details
-
SuggestionsOrdererFeatureExtractor
-
-
Method Details
-
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, computeFeaturesFloat>> (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
-