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.Logger
private boolean
private static final org.apache.commons.pool2.KeyedObjectPool
<Language, ml.dmlc.xgboost4j.java.Booster> private static boolean
Fields inherited from class org.languagetool.rules.spelling.suggestions.SuggestionsOrdererFeatureExtractor
language, languageModel, mistakeProb, score, topN
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static @NotNull String
getModelPath
(Language language) protected void
boolean
orderSuggestions
(List<String> suggestions, String word, AnalyzedSentence sentence, int startPos) static void
setAutoCorrectThresholdForLanguage
(Language lang, float value) For testing purposes onlyboolean
shouldAutoCorrect
(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
computeFeatures
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 -
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:
initParameters
in classSuggestionsOrdererFeatureExtractor
-
isMlAvailable
public boolean isMlAvailable()- Specified by:
isMlAvailable
in interfaceSuggestionsOrderer
- Overrides:
isMlAvailable
in classSuggestionsOrdererFeatureExtractor
-
orderSuggestions
public List<SuggestedReplacement> orderSuggestions(List<String> suggestions, String word, AnalyzedSentence sentence, int startPos) - Specified by:
orderSuggestions
in interfaceSuggestionsOrderer
- Overrides:
orderSuggestions
in classSuggestionsOrdererFeatureExtractor
-
shouldAutoCorrect
Description copied from interface:SuggestionsRanker
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 known- Specified by:
shouldAutoCorrect
in interfaceSuggestionsRanker
- Parameters:
rankedSuggestions
- suggestions returned by orderSuggestions- Returns:
- if confidence is high enough for auto correction
-