public class JLanguageTool extends Object
grammar.xml
)
Rule
classes added with addRule(Rule)
You will probably want to use the sub class MultiThreadedJLanguageTool
for best performance.
Thread-safety: this class is not thread safe. Create one instance per thread,
but create the language only once (e.g. new AmericanEnglish()
) and use it for all
instances of JLanguageTool.
MultiThreadedJLanguageTool
Modifier and Type | Class and Description |
---|---|
static interface |
JLanguageTool.CheckCancelledCallback
Callback for checking if result of
check(String) is still needed. |
static class |
JLanguageTool.Level |
static class |
JLanguageTool.Mode |
static class |
JLanguageTool.ParagraphHandling
Constants for correct paragraph-rule handling.
|
Modifier and Type | Field and Description |
---|---|
static String |
BUILD_DATE
LanguageTool build date and time like
2013-10-17 16:10 or null if not run from JAR. |
static String |
DICTIONARY_FILENAME_EXTENSION
Extension of dictionary files read by Spellers
|
static String |
FALSE_FRIEND_FILE
The name of the file with false friend information.
|
static String |
GIT_SHORT_ID
Abbreviated git id or
null if not available. |
static String |
MESSAGE_BUNDLE
Name of the message bundle for translations.
|
static String |
PARAGRAPH_END_TAGNAME
The internal tag used to mark the end of a paragraph.
|
static String |
PATTERN_FILE
The name of the file with error patterns.
|
static String |
SENTENCE_END_TAGNAME
The internal tag used to mark the end of a sentence.
|
static String |
SENTENCE_START_TAGNAME
The internal tag used to mark the beginning of a sentence.
|
static String |
VERSION
LanguageTool version as a string like
2.3 or 2.4-SNAPSHOT . |
Constructor and Description |
---|
JLanguageTool(Language language)
Create a JLanguageTool and setup the built-in Java rules for the
given language.
|
JLanguageTool(Language lang,
Language motherTongue)
Create a JLanguageTool and setup the built-in rules for the
given language and false friend rules for the text language / mother tongue pair.
|
JLanguageTool(Language language,
Language motherTongue,
ResultCache cache)
Create a JLanguageTool and setup the built-in rules for the
given language and false friend rules for the text language / mother tongue pair.
|
JLanguageTool(Language language,
Language motherTongue,
ResultCache cache,
UserConfig userConfig)
Create a JLanguageTool and setup the built-in rules for the
given language and false friend rules for the text language / mother tongue pair.
|
JLanguageTool(Language language,
List<Language> altLanguages,
Language motherTongue,
ResultCache cache,
GlobalConfig globalConfig,
UserConfig userConfig) |
JLanguageTool(Language language,
List<Language> altLanguages,
Language motherTongue,
ResultCache cache,
GlobalConfig globalConfig,
UserConfig userConfig,
boolean inputLogging)
Create a JLanguageTool and setup the built-in rules for the
given language and false friend rules for the text language / mother tongue pair.
|
JLanguageTool(Language language,
ResultCache cache,
UserConfig userConfig)
Create a JLanguageTool and setup the built-in rules for the
given language and false friend rules for the text language / mother tongue pair.
|
Modifier and Type | Method and Description |
---|---|
void |
activateLanguageModelRules(File indexDir)
Activate rules that depend on a language model.
|
void |
activateNeuralNetworkRules(File modelDir)
Activate rules that depend on pre-trained neural network models.
|
void |
activateRemoteRules(File configFile) |
void |
activateRemoteRules(List<RemoteRuleConfig> configs) |
void |
activateWord2VecModelRules(File indexDir)
Activate rules that depend on a word2vec language model.
|
void |
addMatchFilter(RuleMatchFilter filter)
Add a
RuleMatchFilter for post-processing of rule matches
Filters are called sequentially in the same order as added |
void |
addRule(Rule rule)
Add a rule to be used by the next call to the check methods like
check(String) . |
static void |
addTemporaryFile(File file)
Adds a temporary file to the internal list
(internal method, you should never need to call this as a user of LanguageTool)
|
RuleMatch |
adjustRuleMatchPos(RuleMatch match,
int charCount,
int columnCount,
int lineCount,
String sentence,
AnnotatedText annotatedText)
Change RuleMatch positions so they are relative to the complete text,
not just to the sentence.
|
protected List<AnalyzedSentence> |
analyzeSentences(List<String> sentences) |
List<AnalyzedSentence> |
analyzeText(String text)
Use this method if you want to access LanguageTool's otherwise
internal analysis of the text.
|
protected List<RuleMatch> |
applyCustomFilters(List<RuleMatch> matches,
AnnotatedText text)
should be called just once with complete list of matches, before returning them to caller
|
List<RuleMatch> |
check(AnnotatedText text)
The main check method.
|
List<RuleMatch> |
check(AnnotatedText annotatedText,
boolean tokenizeText,
JLanguageTool.ParagraphHandling paraMode)
The main check method.
|
List<RuleMatch> |
check(AnnotatedText annotatedText,
boolean tokenizeText,
JLanguageTool.ParagraphHandling paraMode,
RuleMatchListener listener)
The main check method.
|
List<RuleMatch> |
check(AnnotatedText annotatedText,
boolean tokenizeText,
JLanguageTool.ParagraphHandling paraMode,
RuleMatchListener listener,
JLanguageTool.Mode mode,
JLanguageTool.Level level)
The main check method.
|
List<RuleMatch> |
check(AnnotatedText annotatedText,
boolean tokenizeText,
JLanguageTool.ParagraphHandling paraMode,
RuleMatchListener listener,
JLanguageTool.Mode mode,
JLanguageTool.Level level,
ExecutorService remoteRulesThreadPool)
The main check method.
|
List<RuleMatch> |
check(AnnotatedText annotatedText,
boolean tokenizeText,
JLanguageTool.ParagraphHandling paraMode,
RuleMatchListener listener,
JLanguageTool.Mode mode,
JLanguageTool.Level level,
ExecutorService remoteRulesThreadPool,
Long textSessionID)
The main check method.
|
List<RuleMatch> |
check(AnnotatedText text,
RuleMatchListener listener) |
List<RuleMatch> |
check(String text)
The main check method.
|
List<RuleMatch> |
check(String text,
boolean tokenizeText,
JLanguageTool.ParagraphHandling paraMode) |
List<RuleMatch> |
check(String text,
boolean tokenizeText,
JLanguageTool.ParagraphHandling paraMode,
RuleMatchListener listener) |
List<RuleMatch> |
check(String text,
RuleMatchListener listener)
The main check method.
|
List<RuleMatch> |
checkAnalyzedSentence(JLanguageTool.ParagraphHandling paraMode,
List<Rule> rules,
AnalyzedSentence analyzedSentence)
Deprecated.
use one of the
check(java.lang.String) methods instead. |
List<RuleMatch> |
checkAnalyzedSentence(JLanguageTool.ParagraphHandling paraMode,
List<Rule> rules,
AnalyzedSentence analyzedSentence,
boolean checkRemoteRules)
This is an internal method that's public only for technical reasons, please use one
of the
check(String) methods instead. |
protected void |
checkRemoteRules(ExecutorService remoteRulesThreadPool,
List<Rule> allRules,
List<AnalyzedSentence> analyzedSentences,
JLanguageTool.Mode mode,
JLanguageTool.Level level,
List<FutureTask<RemoteRuleResult>> remoteRuleTasks,
List<RemoteRule> remoteRules,
Map<Integer,List<RuleMatch>> cachedResults,
Map<Integer,Integer> matchOffset,
Long textSessionID) |
protected List<org.languagetool.JLanguageTool.SentenceData> |
computeSentenceData(List<AnalyzedSentence> analyzedSentences,
List<String> texts) |
void |
disableCategory(CategoryId id)
Disable the given rule category so the check methods like
check(String) won't use it. |
void |
disableRule(String ruleId)
Disable a given rule so the check methods like
check(String) won't use it. |
void |
disableRules(List<String> ruleIds)
Disable the given rules so the check methods like
check(String) won't use them. |
void |
enableRule(String ruleId)
Enable a given rule so the check methods like
check(String) will use it. |
void |
enableRuleCategory(CategoryId id)
Enable all rules of the given category so the check methods like
check(String) will use it. |
protected void |
fetchRemoteRuleResults(JLanguageTool.Mode mode,
JLanguageTool.Level level,
List<AnalyzedSentence> analyzedSentences,
List<RuleMatch> remoteMatches,
List<FutureTask<RemoteRuleResult>> remoteRuleTasks,
List<RemoteRule> remoteRules,
Map<Integer,List<RuleMatch>> cachedResults,
Map<Integer,Integer> matchOffset,
AnnotatedText annotatedText,
Long textSessionID) |
List<Rule> |
getAllActiveOfficeRules()
Works like getAllActiveRules but overrides defaults by office defaults
|
List<Rule> |
getAllActiveRules()
Get all active (not disabled) rules for the current language that are built-in or that
have been added using e.g.
|
List<Rule> |
getAllRules()
Get all rules for the current language that are built-in or that have been
added using
addRule(Rule) . |
List<SpellingCheckRule> |
getAllSpellingCheckRules()
Get all spelling check rules for the current language that are built-in or
that have been added using
addRule(Rule) . |
AnalyzedSentence |
getAnalyzedSentence(String sentence)
Tokenizes the given
sentence into words and analyzes it,
and then disambiguates POS tags. |
Map<CategoryId,Category> |
getCategories()
Get all rule categories for the current language.
|
static ClassBroker |
getClassBroker() |
static ResourceDataBroker |
getDataBroker()
The grammar checker needs resources from following
directories:
/resource
/rules
|
Set<String> |
getDisabledRules()
Get rule ids of the rules that have been explicitly disabled.
|
Language |
getLanguage()
Get the language that was used to configure this instance.
|
static ResourceBundle |
getMessageBundle()
Gets the ResourceBundle (i18n strings) for the default language of the user's system.
|
static ResourceBundle |
getMessageBundle(Language lang)
Gets the ResourceBundle (i18n strings) for the given user interface language.
|
List<AbstractPatternRule> |
getPatternRulesByIdAndSubId(String id,
String subId)
Get pattern rules by Id and SubId.
|
AnalyzedSentence |
getRawAnalyzedSentence(String sentence)
Tokenizes the given
sentence into words and analyzes it. |
List<String> |
getUnknownWords()
Get the alphabetically sorted list of unknown words in the latest run of one of the
check(String) methods. |
boolean |
isCategoryDisabled(CategoryId id)
Returns true if a category is explicitly disabled.
|
static boolean |
isPremiumVersion() |
List<AbstractPatternRule> |
loadFalseFriendRules(String filename)
Load false friend rules from an XML file.
|
List<AbstractPatternRule> |
loadPatternRules(String filename)
Load pattern rules from an XML file.
|
protected List<RuleMatch> |
performCheck(List<AnalyzedSentence> analyzedSentences,
List<String> sentences,
List<Rule> allRules,
JLanguageTool.ParagraphHandling paraMode,
AnnotatedText annotatedText,
JLanguageTool.Mode mode,
JLanguageTool.Level level)
|
protected List<RuleMatch> |
performCheck(List<AnalyzedSentence> analyzedSentences,
List<String> sentenceTexts,
List<Rule> allRules,
JLanguageTool.ParagraphHandling paraMode,
AnnotatedText annotatedText,
RuleMatchListener listener,
JLanguageTool.Mode mode,
JLanguageTool.Level level,
boolean checkRemoteRules)
|
protected List<RuleMatch> |
performCheck(List<AnalyzedSentence> analyzedSentences,
List<String> sentenceTexts,
RuleSet ruleSet,
JLanguageTool.ParagraphHandling paraMode,
AnnotatedText annotatedText,
RuleMatchListener listener,
JLanguageTool.Mode mode,
JLanguageTool.Level level,
boolean checkRemoteRules) |
protected void |
printIfVerbose(String s) |
protected void |
printSentenceInfo(AnalyzedSentence analyzedSentence) |
protected void |
rememberUnknownWords(AnalyzedSentence analyzedText) |
static void |
removeTemporaryFiles()
Clean up all temporary files, if there are any.
|
List<String> |
sentenceTokenize(String text)
Tokenizes the given text into sentences.
|
void |
setCheckCancelledCallback(JLanguageTool.CheckCancelledCallback callback)
Callback to determine if result of executing
check(String) is still needed. |
static void |
setClassBrokerBroker(ClassBroker broker) |
void |
setCleanOverlappingMatches(boolean cleanOverlappingMatches)
Whether the
check(String) methods return overlapping errors. |
void |
setConfigValues(Map<String,Integer> v) |
static void |
setDataBroker(ResourceDataBroker broker)
The grammar checker needs resources from following
directories:
/resource
/rules
|
void |
setListUnknownWords(boolean listUnknownWords)
Whether the
check(String) methods store unknown words. |
void |
setMaxErrorsPerWordRate(float maxErrorsPerWordRate)
Maximum errors per word rate, checking will stop with an exception if the rate is higher.
|
void |
setOutput(PrintStream printStream)
Set a PrintStream that will receive verbose output.
|
public static final String VERSION
2.3
or 2.4-SNAPSHOT
.@Nullable public static final String BUILD_DATE
2013-10-17 16:10
or null
if not run from JAR.@Nullable public static final String GIT_SHORT_ID
null
if not available.public static final String PATTERN_FILE
public static final String FALSE_FRIEND_FILE
public static final String SENTENCE_START_TAGNAME
public static final String SENTENCE_END_TAGNAME
public static final String PARAGRAPH_END_TAGNAME
public static final String MESSAGE_BUNDLE
public static final String DICTIONARY_FILENAME_EXTENSION
public JLanguageTool(Language lang, Language motherTongue)
lang
- the language of the text to be checkedmotherTongue
- the user's mother tongue, used for false friend rules, or null
.
The mother tongue may also be used as a source language for checking bilingual texts.public JLanguageTool(Language language)
language
- the language of the text to be checkedpublic JLanguageTool(Language language, Language motherTongue, ResultCache cache)
language
- the language of the text to be checkedmotherTongue
- the user's mother tongue, used for false friend rules, or null
.
The mother tongue may also be used as a source language for checking bilingual texts.cache
- a cache to speed up checking if the same sentences get checked more than once,
e.g. when LT is running as a server and texts are re-checked due to changespublic JLanguageTool(Language language, ResultCache cache, UserConfig userConfig)
language
- the language of the text to be checkedcache
- a cache to speed up checking if the same sentences get checked more than once,
e.g. when LT is running as a server and texts are re-checked due to changes. Use
null
to deactivate the cache.public JLanguageTool(Language language, List<Language> altLanguages, Language motherTongue, ResultCache cache, GlobalConfig globalConfig, UserConfig userConfig)
public JLanguageTool(Language language, List<Language> altLanguages, Language motherTongue, ResultCache cache, GlobalConfig globalConfig, UserConfig userConfig, boolean inputLogging)
language
- the language of the text to be checkedaltLanguages
- The languages that are accepted as alternative languages - currently this means
words are accepted if they are in an alternative language and not similar to
a word from language
. If there's a similar word in language
,
there will be an error of type RuleMatch.Type#Hint
(EXPERIMENTAL)motherTongue
- the user's mother tongue, used for false friend rules, or null
.
The mother tongue may also be used as a source language for checking bilingual texts.cache
- a cache to speed up checking if the same sentences get checked more than once,
e.g. when LT is running as a server and texts are re-checked due to changesinputLogging
- allow inclusion of input in logs on exceptionspublic JLanguageTool(Language language, Language motherTongue, ResultCache cache, UserConfig userConfig)
language
- the language of the text to be checkedmotherTongue
- the user's mother tongue, used for false friend rules, or null
.
The mother tongue may also be used as a source language for checking bilingual texts.cache
- a cache to speed up checking if the same sentences get checked more than once,
e.g. when LT is running as a server and texts are re-checked due to changespublic static boolean isPremiumVersion()
public static ResourceDataBroker getDataBroker()
/resource
/rules
DefaultResourceDataBroker
will
be instantiated and returned.public static void setDataBroker(ResourceDataBroker broker)
/resource
/rules
broker
- The new resource broker to be used.public static ClassBroker getClassBroker()
DefaultClassBroker
will
be instantiated and returned.public static void setClassBrokerBroker(ClassBroker broker)
broker
- The new class broker to be used.public void setListUnknownWords(boolean listUnknownWords)
check(String)
methods store unknown words. If set to
true
(default: false), you can get the list of unknown words
using getUnknownWords()
.public void setCleanOverlappingMatches(boolean cleanOverlappingMatches)
check(String)
methods return overlapping errors. If set to
true
(default: true), it removes overlapping errors according to
the priorities established for the language.public void setMaxErrorsPerWordRate(float maxErrorsPerWordRate)
public void setCheckCancelledCallback(JLanguageTool.CheckCancelledCallback callback)
check(String)
is still needed.public static ResourceBundle getMessageBundle()
public static ResourceBundle getMessageBundle(Language lang)
public void setOutput(PrintStream printStream)
null
(which is the default) to disable verbose output.public List<AbstractPatternRule> loadPatternRules(String filename) throws IOException
addRule(Rule)
to add these
rules to the checking process.filename
- path to an XML file in the classpath or in the filesystem - the classpath is checked firstPatternRule
objectsIOException
public List<AbstractPatternRule> loadFalseFriendRules(String filename) throws ParserConfigurationException, SAXException, IOException
addRule(Rule)
to add these rules to the
checking process.filename
- path to an XML file in the classpath or in the filesystem - the classpath is checked firstPatternRule
objects, or an empty list if mother tongue is not setParserConfigurationException
SAXException
IOException
public void activateNeuralNetworkRules(File modelDir) throws IOException
modelDir
- root dir of exported modelsIOException
public void activateLanguageModelRules(File indexDir) throws IOException
indexDir
- directory with a '3grams' sub directory which contains a Lucene index with 3gram occurrence countsIOException
public void activateRemoteRules(@Nullable File configFile) throws IOException
IOException
public void activateRemoteRules(List<RemoteRuleConfig> configs) throws IOException
IOException
public void activateWord2VecModelRules(File indexDir) throws IOException
indexDir
- directory with a subdirectories like 'en', each containing dictionary.txt and final_embeddings.txtIOException
public void addMatchFilter(@NotNull RuleMatchFilter filter)
RuleMatchFilter
for post-processing of rule matches
Filters are called sequentially in the same order as addedfilter
- filter to addpublic void addRule(Rule rule)
check(String)
.public void disableRule(String ruleId)
check(String)
won't use it.ruleId
- the id of the rule to disable - no error will be thrown if the id does not existenableRule(String)
public void disableRules(List<String> ruleIds)
check(String)
won't use them.ruleIds
- the ids of the rules to disable - no error will be thrown if the id does not existpublic void disableCategory(CategoryId id)
check(String)
won't use it.id
- the id of the category to disable - no error will be thrown if the id does not existenableRuleCategory(CategoryId)
public boolean isCategoryDisabled(CategoryId id)
id
- the id of the category to check - no error will be thrown if the id does not existdisableCategory(org.languagetool.rules.CategoryId)
public Language getLanguage()
public Set<String> getDisabledRules()
public void enableRule(String ruleId)
check(String)
will use it.
This will not throw an exception if the given rule id doesn't exist.ruleId
- the id of the rule to enabledisableRule(String)
public void enableRuleCategory(CategoryId id)
check(String)
will use it.
This will not throw an exception if the given rule id doesn't exist.disableCategory(org.languagetool.rules.CategoryId)
public List<String> sentenceTokenize(String text)
public List<RuleMatch> check(String text) throws IOException
text
- the text to be checkedRuleMatch
objectsIOException
public List<RuleMatch> check(String text, RuleMatchListener listener) throws IOException
text
- the text to be checkedRuleMatch
objectsIOException
public List<RuleMatch> check(String text, boolean tokenizeText, JLanguageTool.ParagraphHandling paraMode) throws IOException
IOException
public List<RuleMatch> check(String text, boolean tokenizeText, JLanguageTool.ParagraphHandling paraMode, RuleMatchListener listener) throws IOException
IOException
public List<RuleMatch> check(AnnotatedText text) throws IOException
IOException
public List<RuleMatch> check(AnnotatedText text, RuleMatchListener listener) throws IOException
IOException
public List<RuleMatch> check(AnnotatedText annotatedText, boolean tokenizeText, JLanguageTool.ParagraphHandling paraMode) throws IOException
annotatedText
- The text to be checked, created with AnnotatedTextBuilder
.
Call this method with the complete text to be checked. If you call it
repeatedly with smaller chunks like paragraphs or sentence, those rules that work across
paragraphs/sentences won't work (their status gets reset whenever this method is called).tokenizeText
- If true, then the text is tokenized into sentences.
Otherwise, it is assumed it's already tokenized, i.e. it is only one sentenceparaMode
- Uses paragraph-level rules only if true.RuleMatch
objects, describing potential errors in the textIOException
public List<RuleMatch> check(AnnotatedText annotatedText, boolean tokenizeText, JLanguageTool.ParagraphHandling paraMode, RuleMatchListener listener) throws IOException
IOException
public List<RuleMatch> check(AnnotatedText annotatedText, boolean tokenizeText, JLanguageTool.ParagraphHandling paraMode, RuleMatchListener listener, JLanguageTool.Mode mode, JLanguageTool.Level level) throws IOException
mode
.IOException
public List<RuleMatch> check(AnnotatedText annotatedText, boolean tokenizeText, JLanguageTool.ParagraphHandling paraMode, RuleMatchListener listener, JLanguageTool.Mode mode, JLanguageTool.Level level, @Nullable ExecutorService remoteRulesThreadPool) throws IOException
mode
.remoteRulesThreadPool
- when given, starts evaluating remote rules asynchronously before checking other rules,
then waits on result afterwardsIOException
public List<RuleMatch> check(AnnotatedText annotatedText, boolean tokenizeText, JLanguageTool.ParagraphHandling paraMode, RuleMatchListener listener, JLanguageTool.Mode mode, JLanguageTool.Level level, @Nullable ExecutorService remoteRulesThreadPool, @Nullable Long textSessionID) throws IOException
mode
.textSessionID
- UserConfig.getTextSessionID can be outdated because of pipeline pool caching, so pass through directlyIOException
protected void fetchRemoteRuleResults(JLanguageTool.Mode mode, JLanguageTool.Level level, List<AnalyzedSentence> analyzedSentences, List<RuleMatch> remoteMatches, List<FutureTask<RemoteRuleResult>> remoteRuleTasks, List<RemoteRule> remoteRules, Map<Integer,List<RuleMatch>> cachedResults, Map<Integer,Integer> matchOffset, AnnotatedText annotatedText, Long textSessionID)
protected void checkRemoteRules(@NotNull ExecutorService remoteRulesThreadPool, List<Rule> allRules, List<AnalyzedSentence> analyzedSentences, JLanguageTool.Mode mode, JLanguageTool.Level level, List<FutureTask<RemoteRuleResult>> remoteRuleTasks, List<RemoteRule> remoteRules, Map<Integer,List<RuleMatch>> cachedResults, Map<Integer,Integer> matchOffset, Long textSessionID)
public List<AnalyzedSentence> analyzeText(String text) throws IOException
check...
methods instead.text
- The text to be analyzedIOException
protected List<AnalyzedSentence> analyzeSentences(List<String> sentences) throws IOException
IOException
protected void printSentenceInfo(AnalyzedSentence analyzedSentence)
@Deprecated protected List<RuleMatch> performCheck(List<AnalyzedSentence> analyzedSentences, List<String> sentences, List<Rule> allRules, JLanguageTool.ParagraphHandling paraMode, AnnotatedText annotatedText, JLanguageTool.Mode mode, JLanguageTool.Level level) throws IOException
performCheck(List, List, RuleSet, ParagraphHandling, AnnotatedText, RuleMatchListener, Mode, Level, boolean)
IOException
protected List<RuleMatch> performCheck(List<AnalyzedSentence> analyzedSentences, List<String> sentenceTexts, List<Rule> allRules, JLanguageTool.ParagraphHandling paraMode, AnnotatedText annotatedText, RuleMatchListener listener, JLanguageTool.Mode mode, JLanguageTool.Level level, boolean checkRemoteRules) throws IOException
performCheck(List, List, RuleSet, ParagraphHandling, AnnotatedText, RuleMatchListener, Mode, Level, boolean)
IOException
protected List<RuleMatch> performCheck(List<AnalyzedSentence> analyzedSentences, List<String> sentenceTexts, RuleSet ruleSet, JLanguageTool.ParagraphHandling paraMode, AnnotatedText annotatedText, RuleMatchListener listener, JLanguageTool.Mode mode, JLanguageTool.Level level, boolean checkRemoteRules) throws IOException
IOException
protected final List<org.languagetool.JLanguageTool.SentenceData> computeSentenceData(List<AnalyzedSentence> analyzedSentences, List<String> texts)
@Deprecated public List<RuleMatch> checkAnalyzedSentence(JLanguageTool.ParagraphHandling paraMode, List<Rule> rules, AnalyzedSentence analyzedSentence) throws IOException
check(java.lang.String)
methods instead.IOException
public List<RuleMatch> checkAnalyzedSentence(JLanguageTool.ParagraphHandling paraMode, List<Rule> rules, AnalyzedSentence analyzedSentence, boolean checkRemoteRules) throws IOException
check(String)
methods instead.IOException
public RuleMatch adjustRuleMatchPos(RuleMatch match, int charCount, int columnCount, int lineCount, String sentence, AnnotatedText annotatedText)
charCount
- Count of characters in the sentences beforecolumnCount
- Current column numberlineCount
- Current line numbersentence
- The text being checkedprotected void rememberUnknownWords(AnalyzedSentence analyzedText)
public List<String> getUnknownWords()
check(String)
methods.IllegalStateException
- if setListUnknownWords(boolean)
has been set to false
public AnalyzedSentence getAnalyzedSentence(String sentence) throws IOException
sentence
into words and analyzes it,
and then disambiguates POS tags.sentence
- sentence to be analyzedIOException
public AnalyzedSentence getRawAnalyzedSentence(String sentence) throws IOException
sentence
into words and analyzes it.
This is the same as getAnalyzedSentence(String)
but it does not run
the disambiguator.sentence
- sentence to be analyzedIOException
public Map<CategoryId,Category> getCategories()
Categories
, keyed by their id
.public List<Rule> getAllRules()
addRule(Rule)
. Please note that XML rules that are grouped
will appear as multiple rules with the same id. To tell them apart, check if
they are of type AbstractPatternRule
, cast them to that type and call
their AbstractPatternRule.getSubId()
method.Rule
objectspublic List<Rule> getAllActiveRules()
addRule(Rule)
. See getAllRules()
for hints
about rule ids.Rule
objectspublic List<SpellingCheckRule> getAllSpellingCheckRules()
addRule(Rule)
.SpellingCheckRule
objectspublic List<Rule> getAllActiveOfficeRules()
Rule
objectspublic List<AbstractPatternRule> getPatternRulesByIdAndSubId(String id, String subId)
<or>...</or>
are internally expanded into several rules.Rule
objectsprotected void printIfVerbose(String s)
public static void addTemporaryFile(File file)
file
- the file to be added.public static void removeTemporaryFiles()
protected List<RuleMatch> applyCustomFilters(List<RuleMatch> matches, AnnotatedText text)
matches
- matches after applying rules and default filterstext
- text that matches refer tomatchFilters
)