public abstract class SpellingCheckRule extends Rule
| Modifier and Type | Field and Description |
|---|---|
protected Language |
language |
static String |
LANGUAGETOOL
The string
LanguageTool. |
static String |
LANGUAGETOOL_FX
The name of the LanguageTool Firefox extension,
LanguageToolFx. |
| Constructor and Description |
|---|
SpellingCheckRule(ResourceBundle messages,
Language language) |
| Modifier and Type | Method and Description |
|---|---|
void |
addIgnoreTokens(List<String> tokens)
Add the given words to the list of words to be ignored during spell check.
|
protected void |
addIgnoreWords(String line,
Set<String> wordsToBeIgnored) |
protected List<String> |
expandLine(String line)
Expand suffixes in a line.
|
protected void |
filterSuggestions(List<String> suggestions)
Remove prohibited words from suggestions.
|
protected List<String> |
getAdditionalSuggestions(List<String> suggestions,
String word)
Get additional suggestions added after other suggestions (note the rule may choose to
re-order the suggestions anyway).
|
protected List<String> |
getAdditionalTopSuggestions(List<String> suggestions,
String word)
Get additional suggestions added before other suggestions (note the rule may choose to
re-order the suggestions anyway).
|
abstract String |
getDescription()
A short description of the error this rule can detect, usually in the language of the text
that is checked.
|
abstract String |
getId()
A string used to identify the rule in e.g. configuration files.
|
protected String |
getIgnoreFileName()
Get the name of the ignore file, which lists words to be accepted, even
when the spell checker would not accept them.
|
protected String |
getProhibitFileName()
Get the name of the prohibit file, which lists words not to be accepted, even
when the spell checker would accept them.
|
protected String |
getSpellingFileName()
Get the name of the spelling file, which lists words to be accepted
and used for suggestions, even when the spell checker would not accept them.
|
protected boolean |
ignoreToken(AnalyzedTokenReadings[] tokens,
int idx)
Returns true iff the token at the given position should be ignored by the spell checker.
|
protected boolean |
ignoreWord(List<String> words,
int idx)
Returns true iff the word at the given position should be ignored by the spell checker.
|
protected boolean |
ignoreWord(String word)
Returns true iff the word should be ignored by the spell checker.
|
protected void |
init() |
boolean |
isConvertsCase()
Used to check whether the dictionary will use case conversions for
spell checking.
|
boolean |
isDictionaryBasedSpellingRule()
Whether this is a spelling rule that uses a dictionary.
|
protected boolean |
isProhibited(String word)
Whether the word is prohibited, i.e. whether it should be marked as a spelling
error even if the spell checker would accept it.
|
protected boolean |
isUrl(String token) |
abstract RuleMatch[] |
match(AnalyzedSentence sentence)
Check whether the given sentence matches this error rule, i.e. whether it
contains the error detected by this rule.
|
void |
reset()
If a rule keeps its state over more than the check of one sentence, this
must be implemented so the internal state is reset.
|
void |
setConsiderIgnoreWords(boolean considerIgnoreWords)
Set whether the list of words to be explicitly ignored is considered at all.
|
void |
setConvertsCase(boolean convertsCase)
Used to determine whether the dictionary will use case conversions for
spell checking.
|
addExamplePair, getCategory, getCorrectExamples, getIncorrectExamples, getLocQualityIssueType, getUrl, isDefaultOff, setCategory, setCorrectExamples, setDefaultOff, setDefaultOn, setIncorrectExamples, setLocQualityIssueType, setUrl, supportsLanguage, toRuleMatchArray, useInOfficepublic static final String LANGUAGETOOL
LanguageTool.public static final String LANGUAGETOOL_FX
LanguageToolFx.protected final Language language
public SpellingCheckRule(ResourceBundle messages, Language language)
public abstract String getId()
RuleA-Z
and the underscore.public abstract String getDescription()
RulegetDescription in class Rulepublic abstract RuleMatch[] match(AnalyzedSentence sentence) throws IOException
Rulematch in class Rulesentence - a pre-analyzed sentenceRuleMatch objectsIOExceptionpublic boolean isDictionaryBasedSpellingRule()
Ruletrue here are basically rules that work like
a simple hunspell-like spellchecker: they check words without considering
the words' context.isDictionaryBasedSpellingRule in class Rulepublic void reset()
Rulepublic void addIgnoreTokens(List<String> tokens)
public void setConsiderIgnoreWords(boolean considerIgnoreWords)
protected List<String> getAdditionalTopSuggestions(List<String> suggestions, String word) throws IOException
IOExceptionprotected List<String> getAdditionalSuggestions(List<String> suggestions, String word)
protected boolean ignoreToken(AnalyzedTokenReadings[] tokens, int idx) throws IOException
IOExceptionprotected boolean ignoreWord(String word) throws IOException
ignoreToken(org.languagetool.AnalyzedTokenReadings[], int) instead.IOExceptionprotected boolean ignoreWord(List<String> words, int idx) throws IOException
ignoreToken(org.languagetool.AnalyzedTokenReadings[], int) instead.IOExceptionpublic boolean isConvertsCase()
public void setConvertsCase(boolean convertsCase)
convertsCase - if true, then conversions are used.protected boolean isUrl(String token)
protected void init()
throws IOException
IOExceptionprotected String getIgnoreFileName()
getSpellingFileName()
the words in this file will not be used for creating suggestions for misspelled words.protected String getSpellingFileName()
protected String getProhibitFileName()
protected boolean isProhibited(String word)
protected void filterSuggestions(List<String> suggestions)
protected void addIgnoreWords(String line, Set<String> wordsToBeIgnored)
line - the line as read from spelling.txt.wordsToBeIgnored - the set of words to be ignored