Class XGBoostSuggestionsOrderer
java.lang.Object
org.languagetool.rules.spelling.suggestions.SuggestionsOrdererFeatureExtractor
org.languagetool.rules.spelling.suggestions.XGBoostSuggestionsOrderer
- All Implemented Interfaces:
SuggestionsOrderer,SuggestionsRanker
public class XGBoostSuggestionsOrderer
extends SuggestionsOrdererFeatureExtractor
implements SuggestionsRanker
-
Nested Class Summary
Nested classes/interfaces inherited from class org.languagetool.rules.spelling.suggestions.SuggestionsOrdererFeatureExtractor
SuggestionsOrdererFeatureExtractor.Feature -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Loggerprivate booleanprivate static final org.apache.commons.pool2.KeyedObjectPool<Language, ml.dmlc.xgboost4j.java.Booster> private static booleanFields inherited from class org.languagetool.rules.spelling.suggestions.SuggestionsOrdererFeatureExtractor
language, languageModel, mistakeProb, score, topN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static @NotNull StringgetModelPath(Language language) protected voidbooleanorderSuggestions(List<String> suggestions, String word, AnalyzedSentence sentence, int startPos) static voidsetAutoCorrectThresholdForLanguage(Language lang, float value) For testing purposes onlybooleanshouldAutoCorrect(List<SuggestedReplacement> rankedSuggestions) Model output should have been calibrated using a precision-recall curve evaluation, so that a threshold for confidence values with sufficiently high precision for auto correction is knownMethods inherited from class org.languagetool.rules.spelling.suggestions.SuggestionsOrdererFeatureExtractor
computeFeaturesMethods 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 -
modelPool
private static final org.apache.commons.pool2.KeyedObjectPool<Language,ml.dmlc.xgboost4j.java.Booster> modelPool -
autoCorrectThreshold
-
modelClasses
-
candidateFeatureCount
-
matchFeatureCount
-
modelAvailableForLanguage
private boolean modelAvailableForLanguage -
xgboostNotSupported
private static boolean xgboostNotSupported
-
-
Constructor Details
-
XGBoostSuggestionsOrderer
-
-
Method Details
-
getModelPath
-
setAutoCorrectThresholdForLanguage
For testing purposes only -
initParameters
protected void initParameters()- Overrides:
initParametersin classSuggestionsOrdererFeatureExtractor
-
isMlAvailable
public boolean isMlAvailable()- Specified by:
isMlAvailablein interfaceSuggestionsOrderer- Overrides:
isMlAvailablein classSuggestionsOrdererFeatureExtractor
-
orderSuggestions
public List<SuggestedReplacement> orderSuggestions(List<String> suggestions, String word, AnalyzedSentence sentence, int startPos) - Specified by:
orderSuggestionsin interfaceSuggestionsOrderer- Overrides:
orderSuggestionsin classSuggestionsOrdererFeatureExtractor
-
shouldAutoCorrect
Description copied from interface:SuggestionsRankerModel output should have been calibrated using a precision-recall curve evaluation, so that a threshold for confidence values with sufficiently high precision for auto correction is known- Specified by:
shouldAutoCorrectin interfaceSuggestionsRanker- Parameters:
rankedSuggestions- suggestions returned by orderSuggestions- Returns:
- if confidence is high enough for auto correction
-