Class MorfologikSpellerRule
- java.lang.Object
-
- org.languagetool.rules.Rule
-
- org.languagetool.rules.spelling.SpellingCheckRule
-
- org.languagetool.rules.spelling.morfologik.MorfologikSpellerRule
-
public abstract class MorfologikSpellerRule extends SpellingCheckRule
-
-
Field Summary
Fields Modifier and Type Field Description protected Locale
conversionLocale
protected MorfologikMultiSpeller
speller1
protected MorfologikMultiSpeller
speller2
protected MorfologikMultiSpeller
speller3
-
Fields inherited from class org.languagetool.rules.spelling.SpellingCheckRule
ignoreWordsWithLength, language, languageModel, LANGUAGETOOL, LANGUAGETOOLER, wordListLoader
-
-
Constructor Summary
Constructors Constructor Description MorfologikSpellerRule(ResourceBundle messages, Language language)
MorfologikSpellerRule(ResourceBundle messages, Language language, UserConfig userConfig)
MorfologikSpellerRule(ResourceBundle messages, Language language, UserConfig userConfig, List<Language> altLanguages)
MorfologikSpellerRule(ResourceBundle messages, Language language, UserConfig userConfig, List<Language> altLanguages, LanguageModel languageModel)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
getDescription()
A short description of the error this rule can detect, usually in the language of the text that is checked.abstract String
getFileName()
Get the filename, e.g., /resource/pl/spelling.dict.protected int
getFrequency(MorfologikMultiSpeller speller, String word)
abstract String
getId()
A string used to identify the rule in e.g.protected List<RuleMatch>
getRuleMatches(String word, int startPos, AnalyzedSentence sentence, List<RuleMatch> ruleMatchesSoFar, int idx, AnalyzedTokenReadings[] tokens)
protected boolean
ignoreWord(String word)
Ignore surrogate pairs (emojis)boolean
isMisspelled(String word)
protected boolean
isMisspelled(MorfologikMultiSpeller speller, String word)
protected boolean
isSurrogatePairCombination(String word)
Checks whether a given String consists only of surrogate pairs.RuleMatch[]
match(AnalyzedSentence sentence)
Check whether the given sentence matches this error rule, i.e.protected List<String>
orderSuggestions(List<String> suggestions, String word)
protected void
setCheckCompound(boolean checkCompound)
protected void
setCompoundRegex(String compoundRegex)
void
setIgnoreTaggedWords()
Skip words that are known in the POS tagging dictionary, assuming they cannot be incorrect.void
setLocale(Locale locale)
@Nullable Pattern
tokenizingPattern()
Get the regular expression pattern used to tokenize the words as in the source dictionary.-
Methods inherited from class org.languagetool.rules.spelling.SpellingCheckRule
acceptedInAlternativeLanguage, acceptPhrases, addIgnoreTokens, addIgnoreWords, addProhibitedWords, addSuggestionsToRuleMatch, createWrongSplitMatch, expandLine, filterDupes, filterSuggestions, getAdditionalProhibitFileNames, getAdditionalSpellingFileNames, getAdditionalSuggestions, getAdditionalTopSuggestions, getAlternativeLangSpellingRules, getAntiPatterns, getIgnoreFileName, getLanguageVariantSpellingFileName, getProhibitFileName, getSpellingFileName, ignoreToken, ignoreWord, init, isDictionaryBasedSpellingRule, isEMail, isProhibited, isUrl, reorderSuggestions, setConsiderIgnoreWords, setConvertsCase, startsWithIgnoredWord
-
Methods inherited from class org.languagetool.rules.Rule
addExamplePair, estimateContextForSureMatch, getCategory, getConfigureText, getCorrectExamples, getDefaultValue, getErrorTriggeringExamples, getIncorrectExamples, getLocQualityIssueType, getMaxConfigurableValue, getMinConfigurableValue, getSentenceWithImmunization, getUrl, hasConfigurableValue, isDefaultOff, isDefaultTempOff, isOfficeDefaultOff, isOfficeDefaultOn, makeAntiPatterns, setCategory, setCorrectExamples, setDefaultOff, setDefaultOn, setDefaultTempOff, setErrorTriggeringExamples, setIncorrectExamples, setLocQualityIssueType, setOfficeDefaultOff, setOfficeDefaultOn, setUrl, supportsLanguage, toRuleMatchArray, useInOffice
-
-
-
-
Field Detail
-
speller1
protected MorfologikMultiSpeller speller1
-
speller2
protected MorfologikMultiSpeller speller2
-
speller3
protected MorfologikMultiSpeller speller3
-
conversionLocale
protected Locale conversionLocale
-
-
Constructor Detail
-
MorfologikSpellerRule
public MorfologikSpellerRule(ResourceBundle messages, Language language) throws IOException
- Throws:
IOException
-
MorfologikSpellerRule
public MorfologikSpellerRule(ResourceBundle messages, Language language, UserConfig userConfig) throws IOException
- Throws:
IOException
-
MorfologikSpellerRule
public MorfologikSpellerRule(ResourceBundle messages, Language language, UserConfig userConfig, List<Language> altLanguages) throws IOException
- Throws:
IOException
-
MorfologikSpellerRule
public MorfologikSpellerRule(ResourceBundle messages, Language language, UserConfig userConfig, List<Language> altLanguages, LanguageModel languageModel) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getFileName
public abstract String getFileName()
Get the filename, e.g., /resource/pl/spelling.dict.
-
getId
public abstract String getId()
Description copied from class:Rule
A string used to identify the rule in e.g. configuration files. This string is supposed to be unique and to stay the same in all upcoming versions of LanguageTool. It's supposed to contain only the charactersA-Z
and the underscore.- Specified by:
getId
in classSpellingCheckRule
-
getDescription
public String getDescription()
Description copied from class:Rule
A short description of the error this rule can detect, usually in the language of the text that is checked.- Specified by:
getDescription
in classSpellingCheckRule
-
setLocale
public void setLocale(Locale locale)
-
setIgnoreTaggedWords
public void setIgnoreTaggedWords()
Skip words that are known in the POS tagging dictionary, assuming they cannot be incorrect.
-
match
public RuleMatch[] match(AnalyzedSentence sentence) throws IOException
Description copied from class:Rule
Check whether the given sentence matches this error rule, i.e. whether it contains the error detected by this rule. Note that the order in which this method is called is not always guaranteed, i.e. the sentence order in the text may be different than the order in which you get the sentences (this may be the case when LanguageTool is used as a LibreOffice/OpenOffice add-on, for example).- Specified by:
match
in classSpellingCheckRule
- Parameters:
sentence
- a pre-analyzed sentence- Returns:
- an array of
RuleMatch
objects - Throws:
IOException
-
isMisspelled
@Experimental public boolean isMisspelled(String word) throws IOException
- Specified by:
isMisspelled
in classSpellingCheckRule
- Throws:
IOException
- Since:
- 4.8
-
isMisspelled
protected boolean isMisspelled(MorfologikMultiSpeller speller, String word)
- Returns:
- true if the word is misspelled
- Since:
- 2.4
-
getFrequency
protected int getFrequency(MorfologikMultiSpeller speller, String word)
-
getRuleMatches
protected List<RuleMatch> getRuleMatches(String word, int startPos, AnalyzedSentence sentence, List<RuleMatch> ruleMatchesSoFar, int idx, AnalyzedTokenReadings[] tokens) throws IOException
- Throws:
IOException
-
tokenizingPattern
@Nullable public @Nullable Pattern tokenizingPattern()
Get the regular expression pattern used to tokenize the words as in the source dictionary. For example, it may contain a hyphen, if the words with hyphens are not included in the dictionary- Returns:
- A compiled
Pattern
that is used to tokenize words ornull
.
-
setCheckCompound
protected void setCheckCompound(boolean checkCompound)
- Parameters:
checkCompound
- If true and the word is not in the dictionary it will be split (seesetCompoundRegex(String)
) and each component will be checked separately- Since:
- 2.4
-
setCompoundRegex
protected void setCompoundRegex(String compoundRegex)
- Parameters:
compoundRegex
- seesetCheckCompound(boolean)
- Since:
- 2.4
-
isSurrogatePairCombination
protected boolean isSurrogatePairCombination(String word)
Checks whether a given String consists only of surrogate pairs.- Parameters:
word
- to be checked- Since:
- 4.2
-
ignoreWord
protected boolean ignoreWord(String word) throws IOException
Ignore surrogate pairs (emojis)- Overrides:
ignoreWord
in classSpellingCheckRule
- Throws:
IOException
- Since:
- 4.3
- See Also:
SpellingCheckRule.ignoreWord(java.lang.String)
-
-