Class MorfologikSpellerRule
java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.spelling.SpellingCheckRule
org.languagetool.rules.spelling.morfologik.MorfologikSpellerRule
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private Pattern
protected Locale
private boolean
(package private) static final int
private final boolean
protected MorfologikMultiSpeller
protected MorfologikMultiSpeller
protected MorfologikMultiSpeller
private final SuggestionsOrderer
private final UserConfig
Fields inherited from class org.languagetool.rules.spelling.SpellingCheckRule
ignoreWordsWithLength, language, languageModel, LANGUAGETOOL, LANGUAGETOOLER, wordListLoader
-
Constructor Summary
ConstructorsConstructorDescriptionMorfologikSpellerRule
(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
Modifier and TypeMethodDescriptionprivate boolean
canBeIgnored
(AnalyzedTokenReadings[] tokens, int idx, AnalyzedTokenReadings token) A short description of the error this rule can detect, usually in the language of the text that is checked.abstract String
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.getRuleMatches
(String word, int startPos, AnalyzedSentence sentence, List<RuleMatch> ruleMatchesSoFar, int idx, AnalyzedTokenReadings[] tokens) protected boolean
ignoreWord
(String word) Ignore surrogate pairs (emojis)private void
initSpeller
(String binaryDict) private boolean
boolean
isMisspelled
(String word) protected boolean
isMisspelled
(MorfologikMultiSpeller speller, String word) protected boolean
Checks whether a given String consists only of surrogate pairs.joinBeforeAfterSuggestions
(List<String> suggestionsList, String beforeSuggestionStr, String afterSuggestionStr) Join strings before and after a suggestion.match
(AnalyzedSentence sentence) Check whether the given sentence matches this error rule, i.e.orderSuggestions
(List<String> suggestions, String word) orderSuggestions
(List<String> suggestions, String word, AnalyzedSentence sentence, int startPos) protected void
setCheckCompound
(boolean checkCompound) protected void
setCompoundRegex
(String compoundRegex) void
Skip words that are known in the POS tagging dictionary, assuming they cannot be incorrect.void
@Nullable Pattern
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 Details
-
speller1
-
speller2
-
speller3
-
conversionLocale
-
suggestionsOrderer
-
runningExperiment
private final boolean runningExperiment -
ignoreTaggedWords
private boolean ignoreTaggedWords -
checkCompound
private boolean checkCompound -
compoundRegex
-
userConfig
-
MAX_FREQUENCY_FOR_SPLITTING
static final int MAX_FREQUENCY_FOR_SPLITTING- See Also:
-
-
Constructor Details
-
MorfologikSpellerRule
- 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 Details
-
getFileName
Get the filename, e.g., /resource/pl/spelling.dict. -
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
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
-
setIgnoreTaggedWords
public void setIgnoreTaggedWords()Skip words that are known in the POS tagging dictionary, assuming they cannot be incorrect. -
match
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
-
initSpellers
- Throws:
IOException
-
initSpeller
- Throws:
IOException
-
canBeIgnored
private boolean canBeIgnored(AnalyzedTokenReadings[] tokens, int idx, AnalyzedTokenReadings token) throws IOException - Throws:
IOException
-
isMisspelled
- Specified by:
isMisspelled
in classSpellingCheckRule
- Throws:
IOException
- Since:
- 4.8
-
isMisspelled
- Returns:
- true if the word is misspelled
- Since:
- 2.4
-
getFrequency
-
getRuleMatches
protected List<RuleMatch> getRuleMatches(String word, int startPos, AnalyzedSentence sentence, List<RuleMatch> ruleMatchesSoFar, int idx, AnalyzedTokenReadings[] tokens) throws IOException - Throws:
IOException
-
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
.
-
orderSuggestions
-
orderSuggestions
-
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
- Parameters:
compoundRegex
- seesetCheckCompound(boolean)
- Since:
- 2.4
-
isSurrogatePairCombination
Checks whether a given String consists only of surrogate pairs.- Parameters:
word
- to be checked- Since:
- 4.2
-
ignoreWord
Ignore surrogate pairs (emojis)- Overrides:
ignoreWord
in classSpellingCheckRule
- Throws:
IOException
- Since:
- 4.3
- See Also:
-
joinBeforeAfterSuggestions
private List<String> joinBeforeAfterSuggestions(List<String> suggestionsList, String beforeSuggestionStr, String afterSuggestionStr) Join strings before and after a suggestion. Used when there is also suggestion for split words Ex. to thow > tot how | to throw
-