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
Fields Modifier and Type Field Description private static java.util.Map<java.lang.String,java.lang.Float>
autoCorrectThreshold
private static java.util.Map<java.lang.String,java.lang.Integer>
candidateFeatureCount
private static org.slf4j.Logger
logger
private static java.util.Map<java.lang.String,java.lang.Integer>
matchFeatureCount
private boolean
modelAvailableForLanguage
private static java.util.Map<java.lang.String,java.util.List<java.lang.Integer>>
modelClasses
private static org.apache.commons.pool2.KeyedObjectPool<Language,ml.dmlc.xgboost4j.java.Booster>
modelPool
private static boolean
xgboostNotSupported
-
Fields inherited from class org.languagetool.rules.spelling.suggestions.SuggestionsOrdererFeatureExtractor
language, languageModel, mistakeProb, score, topN
-
-
Constructor Summary
Constructors Constructor Description XGBoostSuggestionsOrderer(Language lang, LanguageModel languageModel)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static @NotNull java.lang.String
getModelPath(Language language)
protected void
initParameters()
boolean
isMlAvailable()
java.util.List<SuggestedReplacement>
orderSuggestions(java.util.List<java.lang.String> suggestions, java.lang.String word, AnalyzedSentence sentence, int startPos)
static void
setAutoCorrectThresholdForLanguage(Language lang, float value)
For testing purposes onlyboolean
shouldAutoCorrect(java.util.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 known-
Methods 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 Detail
-
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
private static final java.util.Map<java.lang.String,java.lang.Float> autoCorrectThreshold
-
modelClasses
private static final java.util.Map<java.lang.String,java.util.List<java.lang.Integer>> modelClasses
-
candidateFeatureCount
private static final java.util.Map<java.lang.String,java.lang.Integer> candidateFeatureCount
-
matchFeatureCount
private static final java.util.Map<java.lang.String,java.lang.Integer> matchFeatureCount
-
modelAvailableForLanguage
private boolean modelAvailableForLanguage
-
xgboostNotSupported
private static boolean xgboostNotSupported
-
-
Constructor Detail
-
XGBoostSuggestionsOrderer
public XGBoostSuggestionsOrderer(Language lang, LanguageModel languageModel)
-
-
Method Detail
-
getModelPath
@NotNull private static @NotNull java.lang.String getModelPath(Language language)
-
setAutoCorrectThresholdForLanguage
public static void setAutoCorrectThresholdForLanguage(Language lang, float value)
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 java.util.List<SuggestedReplacement> orderSuggestions(java.util.List<java.lang.String> suggestions, java.lang.String word, AnalyzedSentence sentence, int startPos)
- Specified by:
orderSuggestions
in interfaceSuggestionsOrderer
- Overrides:
orderSuggestions
in classSuggestionsOrdererFeatureExtractor
-
shouldAutoCorrect
public boolean shouldAutoCorrect(java.util.List<SuggestedReplacement> rankedSuggestions)
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
-
-