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 Modifier and Type Class Description private class
MultiThreadedJLanguageTool.AnalyzeSentenceCallable
private class
MultiThreadedJLanguageTool.ParagraphEndAnalyzeSentenceCallable
-
Nested classes/interfaces inherited from class org.languagetool.JLanguageTool
JLanguageTool.Mode, JLanguageTool.ParagraphHandling, JLanguageTool.TextCheckCallable
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.ExecutorService
threadPool
private int
threadPoolSize
-
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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.List<AnalyzedSentence>
analyzeSentences(java.util.List<java.lang.String> sentences)
private java.util.List<java.util.concurrent.Callable<java.util.List<RuleMatch>>>
createTextCheckCallables(JLanguageTool.ParagraphHandling paraMode, AnnotatedText annotatedText, java.util.List<AnalyzedSentence> analyzedSentences, java.util.List<java.lang.String> sentences, java.util.List<Rule> allRules, int charCount, int lineCount, int columnCount, RuleMatchListener listener, JLanguageTool.Mode mode)
private static int
getDefaultThreadCount()
protected java.util.concurrent.ExecutorService
getExecutorService()
protected int
getThreadPoolSize()
When no thread pool size is configured, the number of available processors is returned.protected java.util.List<RuleMatch>
performCheck(java.util.List<AnalyzedSentence> analyzedSentences, java.util.List<java.lang.String> sentences, java.util.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, countLineBreaks, 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
-
getDefaultThreadCount
private static int getDefaultThreadCount()
-
getThreadPoolSize
protected int getThreadPoolSize()
When no thread pool size is configured, the number of available processors is returned.
-
getExecutorService
protected java.util.concurrent.ExecutorService getExecutorService()
- Returns:
- a fixed size executor with the given number of threads
-
analyzeSentences
protected java.util.List<AnalyzedSentence> analyzeSentences(java.util.List<java.lang.String> sentences) throws java.io.IOException
- Overrides:
analyzeSentences
in classJLanguageTool
- Throws:
java.io.IOException
-
performCheck
protected java.util.List<RuleMatch> performCheck(java.util.List<AnalyzedSentence> analyzedSentences, java.util.List<java.lang.String> sentences, java.util.List<Rule> allRules, JLanguageTool.ParagraphHandling paraMode, AnnotatedText annotatedText, RuleMatchListener listener, JLanguageTool.Mode mode)
- Overrides:
performCheck
in classJLanguageTool
-
createTextCheckCallables
private java.util.List<java.util.concurrent.Callable<java.util.List<RuleMatch>>> createTextCheckCallables(JLanguageTool.ParagraphHandling paraMode, AnnotatedText annotatedText, java.util.List<AnalyzedSentence> analyzedSentences, java.util.List<java.lang.String> sentences, java.util.List<Rule> allRules, int charCount, int lineCount, int columnCount, RuleMatchListener listener, JLanguageTool.Mode mode)
-
-