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 class
private final class
Nested classes/interfaces inherited from class org.languagetool.JLanguageTool
JLanguageTool.Mode, JLanguageTool.ParagraphHandling, JLanguageTool.TextCheckCallable
-
Field Summary
FieldsFields 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
ConstructorsConstructorDescriptionMultiThreadedJLanguageTool
(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
Modifier and TypeMethodDescriptionprotected List
<AnalyzedSentence> analyzeSentences
(List<String> sentences) createTextCheckCallables
(JLanguageTool.ParagraphHandling paraMode, AnnotatedText annotatedText, List<AnalyzedSentence> analyzedSentences, List<String> sentences, List<Rule> allRules, int charCount, int lineCount, int columnCount, RuleMatchListener listener, JLanguageTool.Mode mode) private static int
protected ExecutorService
protected int
When no thread pool size is configured, the number of available processors is returned.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
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
-
Field Details
-
threadPoolSize
private final int threadPoolSize -
threadPool
-
-
Constructor Details
-
MultiThreadedJLanguageTool
-
MultiThreadedJLanguageTool
- Parameters:
threadPoolSize
- the number of concurrent threads- 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:
- 2.9 UserConfig added, 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:
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
-
createTextCheckCallables
private List<Callable<List<RuleMatch>>> createTextCheckCallables(JLanguageTool.ParagraphHandling paraMode, AnnotatedText annotatedText, List<AnalyzedSentence> analyzedSentences, List<String> sentences, List<Rule> allRules, int charCount, int lineCount, int columnCount, RuleMatchListener listener, JLanguageTool.Mode mode)
-