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 Languageprotected final LanguageModelprivate static final org.slf4j.Loggerprotected doubleprotected Stringprotected 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 voidbooleanorderSuggestions(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, waitMethods 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:
isMlAvailablein interfaceSuggestionsOrderer
-
orderSuggestions
public List<SuggestedReplacement> orderSuggestions(List<String> suggestions, String word, AnalyzedSentence sentence, int startPos) - Specified by:
orderSuggestionsin 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
-