Package org.languagetool
Class MultiThreadedJLanguageTool
java.lang.Object
org.languagetool.JLanguageTool
org.languagetool.MultiThreadedJLanguageTool
A variant of
JLanguageTool that uses several threads for rule matching.
Use this if you want text checking to be fast and do not care about the
high load that this might cause. Call shutdown() when you don't need
the object anymore.
Also see the javadoc of JLanguageTool.
Thread-safety: this class is not thread-safe, see the remarks at JLanguageTool.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate final classNested classes/interfaces inherited from class org.languagetool.JLanguageTool
JLanguageTool.CheckCancelledCallback, JLanguageTool.CleanToken, JLanguageTool.Level, JLanguageTool.Mode, JLanguageTool.ParagraphHandling, JLanguageTool.SentenceData, JLanguageTool.TextCheckCallable -
Field Summary
FieldsFields inherited from class org.languagetool.JLanguageTool
BUILD_DATE, CUSTOM_PATTERN_FILE, DICTIONARY_FILENAME_EXTENSION, FALSE_FRIEND_FILE, GIT_SHORT_ID, MESSAGE_BUNDLE, PARAGRAPH_END_TAGNAME, PATTERN_FILE, SENTENCE_END_TAGNAME, SENTENCE_START_TAGNAME, STYLE_FILE, VERSION -
Constructor Summary
ConstructorsConstructorDescriptionMultiThreadedJLanguageTool(Language language) MultiThreadedJLanguageTool(Language language, int threadPoolSize) MultiThreadedJLanguageTool(Language language, Language motherTongue) MultiThreadedJLanguageTool(Language language, Language motherTongue, int threadPoolSize, GlobalConfig globalConfig, UserConfig userConfig) MultiThreadedJLanguageTool(Language language, Language motherTongue, int threadPoolSize, UserConfig userConfig) MultiThreadedJLanguageTool(Language language, Language motherTongue, UserConfig userConfig) -
Method Summary
Modifier and TypeMethodDescriptionprotected List<AnalyzedSentence> analyzeSentences(List<String> sentences) private static intprotected ExecutorServiceprotected intWhen no thread pool size is configured, the number of available processors is returned.protected CheckResultsperformCheck(List<AnalyzedSentence> analyzedSentences, List<String> sentenceTexts, RuleSet ruleSet, JLanguageTool.ParagraphHandling paraMode, AnnotatedText annotatedText, RuleMatchListener listener, JLanguageTool.Mode mode, JLanguageTool.Level level, boolean checkRemoteRules, Set<ToneTag> toneTags) voidshutdown()Call this to shut down the internally used thread pool.voidCall this to shut down the internally used thread pool after all running tasks are finished.Methods inherited from class org.languagetool.JLanguageTool
activateLanguageModelRules, activateRemoteRules, activateRemoteRules, addMatchFilter, addRule, addTemporaryFile, adjustRuleMatchPos, analyzeText, applyCustomFilters, check, check, check, check, check, check, check, check, check, check, check, check, check2, check2, checkAnalyzedSentence, checkAnalyzedSentence, checkInternal, checkInternal, computeSentenceData, countLineBreaks, disableCategory, disableRule, disableRules, enableRule, enableRuleCategory, fetchRemoteRuleResults, getAllActiveOfficeRules, getAllActiveRules, getAllRules, getAllSpellingCheckRules, getAnalyzedSentence, getCategories, getClassBroker, getDataBroker, getDisabledRules, getLanguage, getMessageBundle, getMessageBundle, getPatternRulesByIdAndSubId, getRawAnalyzedSentence, getUnknownWords, isCategoryDisabled, isCustomPasswordAuthenticatorUsed, isRuleActiveForLevelAndToneTags, loadFalseFriendRules, loadPatternRules, markAsParagraphEnd, printIfVerbose, printSentenceInfo, rememberUnknownWords, removeTemporaryFiles, sentenceTokenize, setCheckCancelledCallback, setClassBrokerBroker, setCleanOverlappingMatches, setConfigValues, setDataBroker, setListUnknownWords, setMaxErrorsPerWordRate, setOutput, useCustomPasswordAuthenticator
-
Field Details
-
threadPoolSize
private final int threadPoolSize -
threadPool
-
-
Constructor Details
-
MultiThreadedJLanguageTool
-
MultiThreadedJLanguageTool
- Parameters:
threadPoolSize- the number of concurrent threads (use 0 or negative value for a default)- Since:
- 2.9
- See Also:
-
MultiThreadedJLanguageTool
- See Also:
-
MultiThreadedJLanguageTool
- Since:
- 4.2
-
MultiThreadedJLanguageTool
public MultiThreadedJLanguageTool(Language language, Language motherTongue, int threadPoolSize, UserConfig userConfig) - Parameters:
threadPoolSize- the number of concurrent threads- Since:
- 4.2
- See Also:
-
MultiThreadedJLanguageTool
public MultiThreadedJLanguageTool(Language language, Language motherTongue, int threadPoolSize, GlobalConfig globalConfig, UserConfig userConfig) - Parameters:
threadPoolSize- the number of concurrent threads- Since:
- 4.2
- See Also:
-
-
Method Details
-
shutdown
public void shutdown()Call this to shut down the internally used thread pool.- Since:
- 3.0
-
shutdownWhenDone
public void shutdownWhenDone()Call this to shut down the internally used thread pool after all running tasks are finished.- Since:
- 3.1
-
getDefaultThreadCount
private static int getDefaultThreadCount() -
getThreadPoolSize
protected int getThreadPoolSize()When no thread pool size is configured, the number of available processors is returned. -
getExecutorService
- Returns:
- a fixed size executor with the given number of threads
-
analyzeSentences
- Overrides:
analyzeSentencesin classJLanguageTool- Throws:
IOException
-
performCheck
protected CheckResults performCheck(List<AnalyzedSentence> analyzedSentences, List<String> sentenceTexts, RuleSet ruleSet, JLanguageTool.ParagraphHandling paraMode, AnnotatedText annotatedText, RuleMatchListener listener, JLanguageTool.Mode mode, JLanguageTool.Level level, boolean checkRemoteRules, Set<ToneTag> toneTags) - Overrides:
performCheckin classJLanguageTool
-