Package org.languagetool.server
Class TextChecker
java.lang.Object
org.languagetool.server.TextChecker
- Direct Known Subclasses:
V2TextChecker
- Since:
- 3.4
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final AbTestServiceprivate final ResultCacheprivate static final intprivate static final Patternprotected final HTTPServerConfigprotected static final intprivate final DatabaseLoggerprivate static final Stringprivate final ExecutorServiceprivate final LanguageIdentifierprivate final LongList of clients enabled for restricted rules A/B testing.List of languages enabled for restricted rules A/B testing.List of rule IDs enabled for restricted rules A/B testing.List of usernames for A/B testing with restricted rules.private final Set<DatabasePingLogEntry> private static final intprivate static final intprivate long(package private) PipelinePoolprivate final Randomprivate final RequestCounterprivate static final String -
Constructor Summary
ConstructorsConstructorDescriptionTextChecker(HTTPServerConfig config, boolean internalServer, Queue<Runnable> workQueue, RequestCounter reqCounter) -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected voidcheckParams(Map<String, String> parameters) (package private) voidcheckText(AnnotatedText aText, HttpExchange httpExchange, Map<String, String> params, ErrorRequestLimiter errorRequestLimiter, String remoteAddress) (package private) DetectedLanguagedetectLanguageOfString(String text, String fallbackLanguage, List<String> preferredVariants, List<String> noopLangs, List<String> preferredLangs) (package private) DetectedLanguagedetectLanguageOfString(String text, String fallbackLanguage, List<String> preferredVariants, List<String> noopLangs, List<String> preferredLangs, boolean forcePreferredLanguages) private Map<Language, AnnotatedTextBuilder> getBuilderMap(List<FragmentWithLanguage> fragments, Set<Language> maybeUsedLangs) private List<CategoryId> getCategoryIds(String paramName, Map<String, String> parameters) getCommaSeparatedStrings(String paramName, Map<String, String> parameters) getDisabledRuleIds(Map<String, String> parameters) getEnabledRuleIds(Map<String, String> parameters) protected abstract DetectedLanguagegetLanguage(String text, Map<String, String> parameters, List<String> preferredVariants, List<String> additionalDetectLangs, List<String> preferredLangs, boolean testMode) protected abstract booleangetLanguageAutoDetect(Map<String, String> parameters) private LanguagegetLanguageVariantForCode(String langCode, List<String> preferredVariants) private List<CheckResults> getPipelineResults(AnnotatedText aText, Language lang, Language motherTongue, TextChecker.QueryParams params, UserConfig userConfig, RuleMatchListener listener) getPreferredVariants(Map<String, String> parameters) protected abstract StringgetResponse(AnnotatedText text, Language language, DetectedLanguage lang, Language motherTongue, List<CheckResults> matches, List<RuleMatch> hiddenMatches, String incompleteResultReason, int compactMode, boolean showPremiumHint, JLanguageTool.Mode mode) private List<CheckResults> getRuleMatches(AnnotatedText aText, Language lang, Language motherTongue, Map<String, String> parameters, TextChecker.QueryParams params, UserConfig userConfig, RuleMatchListener listener) getRuleValues(Map<String, String> parameters) getUserDictWords(UserLimits limits, List<String> groups) getUserRules(UserLimits limits, Language lang, List<String> groups) private booleanisOptInThirdPartyAI(UserLimits limits, Map<String, String> params, HTTPServerConfig config) protected static LanguageparseLanguage(String code) private voidprotected abstract voidsetHeaders(HttpExchange httpExchange) private booleanshouldRunRestrictedRulesTest(Map<String, String> params, String agent, Language lang, List<String> abTest) (package private) void
-
Field Details
-
PINGS_CLEAN_MILLIS
private static final int PINGS_CLEAN_MILLIS- See Also:
-
PINGS_MAX_SIZE
private static final int PINGS_MAX_SIZE- See Also:
-
SPAN_NAME_PREFIX
- See Also:
-
COMMA_WHITESPACE_PATTERN
-
AB_TEST_SERVICE
-
CONTEXT_SIZE
protected static final int CONTEXT_SIZE- See Also:
-
config
-
ENCODING
- See Also:
-
CACHE_STATS_PRINT
private static final int CACHE_STATS_PRINT- See Also:
-
languageCheckCounts
-
workQueue
-
reqCounter
-
languageIdentifier
-
executorService
-
cache
-
databaseLogger
-
logServerId
-
random
-
pings
-
pingsCleanDateMillis
private long pingsCleanDateMillis -
pipelinePool
PipelinePool pipelinePool -
onlyTestUsers
List of usernames for A/B testing with restricted rules. Populated from LT_TEST_ONLY_USERS environment variable. Format: comma-separated list of usernames -
onlyTestRules
List of rule IDs enabled for restricted rules A/B testing. Populated from LT_TEST_ONLY_RULES environment variable. Format: comma-separated list of rule IDs -
onlyTestLanguages
List of languages enabled for restricted rules A/B testing. Populated from LT_TEST_ONLY_LANGUAGES environment variable. Format: comma-separated list of language codes -
onlyTestClients
List of clients enabled for restricted rules A/B testing. Populated from LT_TEST_ONLY_CLIENTS environment variable. Format: comma-separated list of client identifiers
-
-
Constructor Details
-
TextChecker
TextChecker(HTTPServerConfig config, boolean internalServer, Queue<Runnable> workQueue, RequestCounter reqCounter)
-
-
Method Details
-
setHeaders
-
getResponse
protected abstract String getResponse(AnnotatedText text, Language language, DetectedLanguage lang, Language motherTongue, List<CheckResults> matches, List<RuleMatch> hiddenMatches, String incompleteResultReason, int compactMode, boolean showPremiumHint, JLanguageTool.Mode mode) -
getPreferredVariants
-
getLanguage
-
getLanguageAutoDetect
-
getEnabledRuleIds
-
getDisabledRuleIds
-
parseLanguage
- Throws:
BadRequestException
-
prewarmPipelinePool
private void prewarmPipelinePool() -
shutdownNow
void shutdownNow() -
isOptInThirdPartyAI
private boolean isOptInThirdPartyAI(UserLimits limits, Map<String, String> params, HTTPServerConfig config) -
shouldRunRestrictedRulesTest
-
checkText
void checkText(AnnotatedText aText, HttpExchange httpExchange, Map<String, String> params, ErrorRequestLimiter errorRequestLimiter, String remoteAddress) throws Exception- Throws:
Exception
-
checkerQueueAlmostFull
public boolean checkerQueueAlmostFull() -
getRuleMatchCount
-
getRuleValues
-
getUserDictWords
-
getUserRules
-
checkParams
-
getRuleMatches
private List<CheckResults> getRuleMatches(AnnotatedText aText, Language lang, Language motherTongue, Map<String, String> parameters, TextChecker.QueryParams params, UserConfig userConfig, RuleMatchListener listener) throws Exception- Throws:
Exception
-
getLanguageVariantForCode
-
getPipelineResults
private List<CheckResults> getPipelineResults(AnnotatedText aText, Language lang, Language motherTongue, TextChecker.QueryParams params, UserConfig userConfig, RuleMatchListener listener) throws Exception - Throws:
Exception
-
getBuilderMap
@NotNull private Map<Language,AnnotatedTextBuilder> getBuilderMap(List<FragmentWithLanguage> fragments, Set<Language> maybeUsedLangs) -
getCategoryIds
-
getCommaSeparatedStrings
-
detectLanguageOfString
-
detectLanguageOfString
-