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 booleanprivate Patternprotected Localeprivate boolean(package private) static final intprivate final booleanprotected MorfologikMultiSpellerprotected MorfologikMultiSpellerprotected MorfologikMultiSpellerprivate final SuggestionsOrdererprivate final UserConfigFields 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 booleancanBeIgnored(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 StringGet the filename, e.g., /resource/pl/spelling.dict.protected intgetFrequency(MorfologikMultiSpeller speller, String word) abstract StringgetId()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 booleanignoreWord(String word) Ignore surrogate pairs (emojis)private voidinitSpeller(String binaryDict) private booleanbooleanisMisspelled(String word) protected booleanisMisspelled(MorfologikMultiSpeller speller, String word) protected booleanChecks 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 voidsetCheckCompound(boolean checkCompound) protected voidsetCompoundRegex(String compoundRegex) voidSkip words that are known in the POS tagging dictionary, assuming they cannot be incorrect.void@Nullable PatternGet 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, startsWithIgnoredWordMethods 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:RuleA 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-Zand the underscore.- Specified by:
getIdin classSpellingCheckRule
-
getDescription
Description copied from class:RuleA short description of the error this rule can detect, usually in the language of the text that is checked.- Specified by:
getDescriptionin 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:RuleCheck 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:
matchin classSpellingCheckRule- Parameters:
sentence- a pre-analyzed sentence- Returns:
- an array of
RuleMatchobjects - 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:
isMisspelledin 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
Patternthat 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:
ignoreWordin 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
-