Class SuggestionsOrdererFeatureExtractor
- java.lang.Object
-
- org.languagetool.rules.spelling.suggestions.SuggestionsOrdererFeatureExtractor
-
- All Implemented Interfaces:
SuggestionsOrderer
- Direct Known Subclasses:
XGBoostSuggestionsOrderer
public class SuggestionsOrdererFeatureExtractor extends java.lang.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classSuggestionsOrdererFeatureExtractor.Feature
-
Field Summary
Fields Modifier and Type Field Description protected Languagelanguageprotected LanguageModellanguageModelprivate static org.slf4j.Loggerloggerprotected doublemistakeProbprotected java.lang.Stringscoreprotected inttopN
-
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<java.util.List<SuggestedReplacement>,java.util.SortedMap<java.lang.String,java.lang.Float>>computeFeatures(java.util.List<java.lang.String> suggestions, java.lang.String word, AnalyzedSentence sentence, int startPos)compute features for training or prediction of a ranking model for suggestionsprotected voidinitParameters()booleanisMlAvailable()java.util.List<SuggestedReplacement>orderSuggestions(java.util.List<java.lang.String> suggestions, java.lang.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
-
logger
private static final org.slf4j.Logger logger
-
language
protected final Language language
-
languageModel
protected final LanguageModel languageModel
-
topN
protected int topN
-
score
protected java.lang.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:
isMlAvailablein interfaceSuggestionsOrderer
-
orderSuggestions
public java.util.List<SuggestedReplacement> orderSuggestions(java.util.List<java.lang.String> suggestions, java.lang.String word, AnalyzedSentence sentence, int startPos)
- Specified by:
orderSuggestionsin interfaceSuggestionsOrderer
-
computeFeatures
public org.apache.commons.lang3.tuple.Pair<java.util.List<SuggestedReplacement>,java.util.SortedMap<java.lang.String,java.lang.Float>> computeFeatures(java.util.List<java.lang.String> suggestions, java.lang.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
-
-