Class MorfologikSpellerRule
java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.spelling.SpellingCheckRule
org.languagetool.rules.spelling.morfologik.MorfologikSpellerRule
- Direct Known Subclasses:
AbstractEnglishSpellerRule,MorfologikAsturianSpellerRule,MorfologikBelarusianSpellerRule,MorfologikBretonSpellerRule,MorfologikCatalanSpellerRule,MorfologikCrimeanTatarSpellerRule,MorfologikDutchSpellerRule,MorfologikFrenchSpellerRule,MorfologikGermanyGermanSpellerRule,MorfologikGreekSpellerRule,MorfologikIrishSpellerRule,MorfologikItalianSpellerRule,MorfologikPolishSpellerRule,MorfologikPortugueseSpellerRule,MorfologikRomanianSpellerRule,MorfologikRussianSpellerRule,MorfologikRussianYOSpellerRule,MorfologikSlovakSpellerRule,MorfologikSlovenianSpellerRule,MorfologikSpanishSpellerRule,MorfologikTagalogSpellerRule,MorfologikUkrainianSpellerRule
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate Patternprotected Localeprotected final GlobalConfigprivate booleanprivate static final org.slf4j.Logger(package private) static final intprotected final Languageprivate static final Patternprivate static final Patternprotected MorfologikMultiSpellerprotected MorfologikMultiSpellerprotected MorfologikMultiSpellerprivate final UserConfigFields inherited from class org.languagetool.rules.spelling.SpellingCheckRule
CUSTOM_SPELLING_FILE, GLOBAL_SPELLING_FILE, HIGH_CONFIDENCE, ignoreWordsWithLength, language, languageModel, LANGUAGETOOL, LANGUAGETOOLER, MAX_TOKEN_LENGTH, wordListLoader, wordsToBeIgnored -
Constructor Summary
ConstructorsConstructorDescriptionMorfologikSpellerRule(ResourceBundle messages, Language language) MorfologikSpellerRule(ResourceBundle messages, Language language, GlobalConfig globalConfig, UserConfig userConfig, List<Language> altLanguages, LanguageModel languageModel, Language motherTongue) MorfologikSpellerRule(ResourceBundle messages, Language language, UserConfig userConfig) MorfologikSpellerRule(ResourceBundle messages, Language language, UserConfig userConfig, List<Language> altLanguages) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddHyphenSuggestions(String[] split, List<SuggestedReplacement> topSuggestions) private Supplier<List<SuggestedReplacement>> appendLazySuggestions(String word, String beforeSuggestionStr, String afterSuggestionStr, boolean fullResults, List<SuggestedReplacement> prev) private List<SuggestedReplacement> calcSpellerSuggestions(String word, boolean fullResults) private 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.private static 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 TranslatorgetTranslator(GlobalConfig globalConfig) protected booleanignoreWord(String word) Ignore surrogate pairs (emojis)private voidinitSpeller(String binaryDict) private booleanbooleanisMisspelled(String word) protected booleanisMisspelled(MorfologikMultiSpeller speller, String word) private static List<SuggestedReplacement> joinBeforeAfterSuggestions(List<SuggestedReplacement> 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.private static List<SuggestedReplacement> protected List<SuggestedReplacement> orderSuggestions(List<SuggestedReplacement> suggestions, String word) protected voidsetCheckCompound(boolean checkCompound) protected voidsetCompoundRegex(String compoundRegex) voidSkip words that are known in the POS tagging dictionary, assuming they cannot be incorrect.voidGet the regular expression pattern used to tokenize the words as in the source dictionary.Methods inherited from class org.languagetool.rules.spelling.SpellingCheckRule
acceptPhrases, addIgnoreTokens, addIgnoreWords, addProhibitedWords, addSuggestionsToRuleMatch, createWrongSplitMatch, expandLine, filterDupes, filterNoSuggestWords, filterSuggestions, getAdditionalProhibitFileNames, getAdditionalSpellingFileNames, getAdditionalSuggestions, getAdditionalTopSuggestions, getAntiPatterns, getIgnoreFileName, getLanguageVariantSpellingFileName, getOnlySuggestions, getProhibitFileName, getSpellingFileName, ignorePotentiallyMisspelledWord, ignoreToken, ignoreWord, init, isDictionaryBasedSpellingRule, isEMail, isIgnoredNoCase, isInIgnoredSet, isLatinScript, isProhibited, isUrl, setConsiderIgnoreWords, setConvertsCase, startsWithIgnoredWord, tokenizeNewWordsMethods inherited from class org.languagetool.rules.Rule
addExamplePair, addTags, addToneTags, cacheAntiPatterns, estimateContextForSureMatch, getCategory, getCorrectExamples, getDistanceTokens, getErrorTriggeringExamples, getFullId, getIncorrectExamples, getLocQualityIssueType, getMinPrevMatches, getPriority, getRuleOptions, getSentenceWithImmunization, getSourceFile, getSubId, getTags, getToneTags, getUrl, hasTag, hasToneTag, isDefaultOff, isDefaultTempOff, isGoalSpecific, isIncludedInHiddenMatches, isOfficeDefaultOff, isOfficeDefaultOn, isPremium, makeAntiPatterns, setCategory, setCorrectExamples, setDefaultOff, setDefaultOn, setDefaultTempOff, setDistanceTokens, setErrorTriggeringExamples, setExamplePair, setGoalSpecific, setIncludedInHiddenMatches, setIncorrectExamples, setLocQualityIssueType, setMinPrevMatches, setOfficeDefaultOff, setOfficeDefaultOn, setPremium, setPriority, setTags, setToneTags, setUrl, supportsLanguage, toRuleMatchArray, useInOffice
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
speller1
-
speller2
-
speller3
-
conversionLocale
-
motherTongue
-
globalConfig
-
ignoreTaggedWords
private boolean ignoreTaggedWords -
checkCompound
private boolean checkCompound -
compoundRegex
-
userConfig
-
MAX_FREQUENCY_FOR_SPLITTING
static final int MAX_FREQUENCY_FOR_SPLITTING- See Also:
-
pStartsWithNumbersBullets
-
pStartsWithNumbersBulletsExceptions
-
-
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, GlobalConfig globalConfig, UserConfig userConfig, List<Language> altLanguages, LanguageModel languageModel, Language motherTongue) 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 from 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). In other words, implementations must be stateless, so that a previous call to this method has no influence on later calls.- Specified by:
matchin classSpellingCheckRule- Parameters:
sentence- a pre-analyzed sentence- Returns:
- an array of
RuleMatchobjects - Throws:
IOException
-
getTranslator
-
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
-
appendLazySuggestions
private Supplier<List<SuggestedReplacement>> appendLazySuggestions(String word, String beforeSuggestionStr, String afterSuggestionStr, boolean fullResults, List<SuggestedReplacement> prev) -
calcSpellerSuggestions
private List<SuggestedReplacement> calcSpellerSuggestions(String word, boolean fullResults) throws IOException - Throws:
IOException
-
addHyphenSuggestions
protected void addHyphenSuggestions(String[] split, List<SuggestedReplacement> topSuggestions) throws IOException - Throws:
IOException
-
mergeSuggestionsWithSameTranslation
@NotNull private static List<SuggestedReplacement> mergeSuggestionsWithSameTranslation(List<SuggestedReplacement> l) -
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
protected List<SuggestedReplacement> orderSuggestions(List<SuggestedReplacement> suggestions, String word) -
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
-
ignoreWord
Ignore surrogate pairs (emojis)- Overrides:
ignoreWordin classSpellingCheckRule- Throws:
IOException- Since:
- 4.3
- See Also:
-
joinBeforeAfterSuggestions
private static List<SuggestedReplacement> joinBeforeAfterSuggestions(List<SuggestedReplacement> 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 -
getSpellingSuggestions
- Throws:
IOException
-