Package org.languagetool
Class MultiThreadedJLanguageTool
- java.lang.Object
-
- org.languagetool.JLanguageTool
-
- org.languagetool.MultiThreadedJLanguageTool
-
public class MultiThreadedJLanguageTool extends JLanguageTool
A variant ofJLanguageTool
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. Callshutdown()
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 classes/interfaces inherited from class org.languagetool.JLanguageTool
JLanguageTool.Mode, JLanguageTool.ParagraphHandling
-
-
Field Summary
-
Fields inherited from class org.languagetool.JLanguageTool
BUILD_DATE, DICTIONARY_FILENAME_EXTENSION, FALSE_FRIEND_FILE, GIT_SHORT_ID, MESSAGE_BUNDLE, PARAGRAPH_END_TAGNAME, PATTERN_FILE, SENTENCE_END_TAGNAME, SENTENCE_START_TAGNAME, VERSION
-
-
Constructor Summary
Constructors Constructor Description MultiThreadedJLanguageTool(Language language)
MultiThreadedJLanguageTool(Language language, int threadPoolSize)
MultiThreadedJLanguageTool(Language language, Language motherTongue)
MultiThreadedJLanguageTool(Language language, Language motherTongue, int threadPoolSize, UserConfig userConfig)
MultiThreadedJLanguageTool(Language language, Language motherTongue, UserConfig userConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<AnalyzedSentence>
analyzeSentences(List<String> sentences)
protected ExecutorService
getExecutorService()
protected int
getThreadPoolSize()
When no thread pool size is configured, the number of available processors is returned.protected List<RuleMatch>
performCheck(List<AnalyzedSentence> analyzedSentences, List<String> sentences, List<Rule> allRules, JLanguageTool.ParagraphHandling paraMode, AnnotatedText annotatedText, RuleMatchListener listener, JLanguageTool.Mode mode)
void
shutdown()
Call this to shut down the internally used thread pool.void
shutdownWhenDone()
Call this to shut down the internally used thread pool after all running tasks are finished.-
Methods inherited from class org.languagetool.JLanguageTool
activateLanguageModelRules, activateNeuralNetworkRules, activateWord2VecModelRules, addMatchFilter, addRule, addTemporaryFile, adjustRuleMatchPos, analyzeText, applyCustomFilters, check, check, check, check, check, check, check, check, check, checkAnalyzedSentence, disableCategory, disableRule, disableRules, enableRule, enableRuleCategory, getAllActiveOfficeRules, getAllActiveRules, getAllRules, getAnalyzedSentence, getCategories, getDataBroker, getDisabledRules, getLanguage, getMessageBundle, getMessageBundle, getPatternRulesByIdAndSubId, getRawAnalyzedSentence, getUnknownWords, isCategoryDisabled, isPremiumVersion, loadFalseFriendRules, loadPatternRules, performCheck, printIfVerbose, printSentenceInfo, rememberUnknownWords, removeTemporaryFiles, sentenceTokenize, setCleanOverlappingMatches, setConfigValues, setDataBroker, setListUnknownWords, setMaxErrorsPerWordRate, setOutput
-
-
-
-
Constructor Detail
-
MultiThreadedJLanguageTool
public MultiThreadedJLanguageTool(Language language)
-
MultiThreadedJLanguageTool
public MultiThreadedJLanguageTool(Language language, int threadPoolSize)
- Parameters:
threadPoolSize
- the number of concurrent threads- Since:
- 2.9
- See Also:
shutdown()
-
MultiThreadedJLanguageTool
public MultiThreadedJLanguageTool(Language language, Language motherTongue)
- See Also:
shutdown()
-
MultiThreadedJLanguageTool
public MultiThreadedJLanguageTool(Language language, Language motherTongue, UserConfig userConfig)
- Since:
- 4.2
-
MultiThreadedJLanguageTool
public MultiThreadedJLanguageTool(Language language, Language motherTongue, int threadPoolSize, UserConfig userConfig)
- Parameters:
threadPoolSize
- the number of concurrent threads- Since:
- 2.9 UserConfig added, 4.2
- See Also:
shutdown()
-
-
Method Detail
-
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
-
getThreadPoolSize
protected int getThreadPoolSize()
When no thread pool size is configured, the number of available processors is returned.
-
getExecutorService
protected ExecutorService getExecutorService()
- Returns:
- a fixed size executor with the given number of threads
-
analyzeSentences
protected List<AnalyzedSentence> analyzeSentences(List<String> sentences) throws IOException
- Overrides:
analyzeSentences
in classJLanguageTool
- Throws:
IOException
-
performCheck
protected List<RuleMatch> performCheck(List<AnalyzedSentence> analyzedSentences, List<String> sentences, List<Rule> allRules, JLanguageTool.ParagraphHandling paraMode, AnnotatedText annotatedText, RuleMatchListener listener, JLanguageTool.Mode mode)
- Overrides:
performCheck
in classJLanguageTool
-
-