|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectJLanguageTool
public final class JLanguageTool
The main class used for checking text against different rules:
loadPatternRules(String)
Rule classes added with
addRule(Rule)
Note that the constructors create a language checker that uses the built-in rules only. Other rules (e.g. from XML) need to be added explicitly.
| Nested Class Summary | |
|---|---|
static class |
JLanguageTool.paragraphHandling
Constants for correct paragraph-rule handling. |
| Field Summary | |
|---|---|
static String |
FALSE_FRIEND_FILE
|
static String |
PARAGRAPH_END_TAGNAME
|
static String |
PATTERN_FILE
|
static String |
RULES_DIR
|
static String |
SENTENCE_END_TAGNAME
|
static String |
SENTENCE_START_TAGNAME
|
static String |
VERSION
|
| Constructor Summary | |
|---|---|
JLanguageTool(Language language)
Create a JLanguageTool and setup the built-in rules appropriate for the given language, ignoring false friend hints. |
|
JLanguageTool(Language language,
Language motherTongue)
Create a JLanguageTool and setup the built-in rules appropriate for the given language. |
|
| Method Summary | |
|---|---|
void |
activateDefaultFalseFriendRules()
Loads and activates the false friend rules from rules/false-friends.xml. |
void |
activateDefaultPatternRules()
Loads and activates the pattern rules from rules/<language>/grammar.xml. |
void |
addRule(Rule rule)
Add a rule to be used by the next call to check(java.lang.String). |
List<RuleMatch> |
check(String text)
The main check method. |
List<RuleMatch> |
check(String text,
boolean tokenizeText,
JLanguageTool.paragraphHandling paraMode)
The main check method. |
void |
disableCategory(String categoryName)
Disable a given category so check(java.lang.String) won't use it. |
void |
disableRule(String ruleId)
Disable a given rule so check(java.lang.String) won't use it. |
void |
enableDefaultOffRule(String ruleId)
Enable a rule that was switched off by default. |
void |
enableRule(String ruleId)
Re-enable a given rule so check(java.lang.String) will use it. |
List<Rule> |
getAllRules()
Get all rules for the current language that are built-in or that have been added using addRule(de.danielnaber.languagetool.rules.Rule). |
AnalyzedSentence |
getAnalyzedSentence(String sentence)
Tokenizes the given sentence into words and analyzes it,
and then disambiguates POS tags. |
Set<String> |
getDisabledCategories()
Get category ids of the rules that have been explicitly disabled. |
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 for the default language of the user's system. |
AnalyzedSentence |
getRawAnalyzedSentence(String sentence)
Tokenizes the given sentence into words and analyzes it. |
int |
getSentenceCount()
Number of sentences the latest call to check() has checked. |
List<String> |
getUnknownWords()
Get the list of unknown words in the last run of the check() method. |
List<PatternRule> |
loadFalseFriendRules(String filename)
Load false friend rules from an XML file. |
List<PatternRule> |
loadPatternRules(String filename)
Load pattern rules from an XML file. |
List<String> |
sentenceTokenize(String text)
Returns tokenized sentences. |
void |
setListUnknownWords(boolean listUnknownWords)
Whether the check() method stores unknown words. |
void |
setOutput(PrintStream printStream)
Set a PrintStream that will receive verbose output. |
| Methods inherited from class Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String VERSION
public static final String RULES_DIR
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
| Constructor Detail |
|---|
public JLanguageTool(Language language)
throws IOException
IOException
public JLanguageTool(Language language,
Language motherTongue)
throws IOException
language - the language to be used.motherTongue - the user's mother tongue or null
IOException| Method Detail |
|---|
public void setListUnknownWords(boolean listUnknownWords)
true (default: false), you can get the list of unknown words
using getUnknownWords().
public static ResourceBundle getMessageBundle()
public void setOutput(PrintStream printStream)
null to disable verbose output.
public List<PatternRule> loadPatternRules(String filename)
throws IOException
addRule(de.danielnaber.languagetool.rules.Rule) to add these
rules to the checking process.
PatternRule objects
ParserConfigurationException
SAXException
IOException
public List<PatternRule> loadFalseFriendRules(String filename)
throws ParserConfigurationException,
SAXException,
IOException
addRule(de.danielnaber.languagetool.rules.Rule) to add these rules to the
checking process.
PatternRule objects
ParserConfigurationException
SAXException
IOException
public void activateDefaultPatternRules()
throws IOException
rules/<language>/grammar.xml.
ParserConfigurationException
SAXException
IOException
public void activateDefaultFalseFriendRules()
throws ParserConfigurationException,
SAXException,
IOException
rules/false-friends.xml.
ParserConfigurationException
SAXException
IOExceptionpublic void addRule(Rule rule)
check(java.lang.String).
public void disableRule(String ruleId)
check(java.lang.String) won't use it.
ruleId - the id of the rule to disablepublic void disableCategory(String categoryName)
check(java.lang.String) won't use it.
categoryName - the id of the category to disablepublic Language getLanguage()
public Set<String> getDisabledRules()
public void enableDefaultOffRule(String ruleId)
ruleId - the id of the turned off rule to enable.public Set<String> getDisabledCategories()
public void enableRule(String ruleId)
check(java.lang.String) will use it.
ruleId - the id of the rule to enablepublic List<String> sentenceTokenize(String text)
public List<RuleMatch> check(String text)
throws IOException
text - the text to check
RuleMatch objects
IOException
public List<RuleMatch> check(String text,
boolean tokenizeText,
JLanguageTool.paragraphHandling paraMode)
throws IOException
text - the text to checktokenizeText - If true, then the text is tokenized into sentences.
Otherwise, it is assumed it's already tokenized.paraMode - Uses paragraph-level rules only if true.
RuleMatch objects
IOExceptionpublic List<String> getUnknownWords()
IllegalStateException - listUnknownWords is set to false
public AnalyzedSentence getAnalyzedSentence(String sentence)
throws IOException
sentence into words and analyzes it,
and then disambiguates POS tags.
IOException
public AnalyzedSentence getRawAnalyzedSentence(String sentence)
throws IOException
sentence into words and analyzes it.
sentence - Sentence to be analyzed
IOExceptionpublic List<Rule> getAllRules()
addRule(de.danielnaber.languagetool.rules.Rule).
Rule objectspublic int getSentenceCount()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||