Class HunspellRule
java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.spelling.SpellingCheckRule
org.languagetool.rules.spelling.hunspell.HunspellRule
- Direct Known Subclasses:
ArabicHunspellSpellerRule,CompoundAwareHunspellRule,HunspellNoSuggestionRule,KhmerHunspellRule
A hunspell-based spellchecking-rule.
The default dictionary is set to the first country variant on the list - so the order
in the Language class declaration is important!
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ConcurrentLinkedQueue<String> private final List<RuleWithLanguage> protected static final Stringprotected HunspellDictionaryprivate static final ConcurrentMap<URL, List<String>> private static final org.slf4j.Loggerprivate final Patternprivate static final booleanprivate booleanprivate static final Stringprivate static final Patternprotected Patternprivate static final ConcurrentMap<String, Pattern> static final Stringprivate static final Patternprivate final UserConfigprivate static final String[]Fields 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
ConstructorsConstructorDescriptionHunspellRule(ResourceBundle messages, Language language, UserConfig userConfig) HunspellRule(ResourceBundle messages, Language language, UserConfig userConfig, List<Language> altLanguages) HunspellRule(ResourceBundle messages, Language language, UserConfig userConfig, List<Language> altLanguages, LanguageModel languageModel) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanacceptSuggestion(String suggestion) private voidprivate List<SuggestedReplacement> calcSuggestions(String word, String cleanWord) private static PatterncomputeNonWordPattern(InputStream stream) private static Stringprotected final voidprivate static voidfileCopy(InputStream in, File targetFile) A short description of the error this rule can detect, usually in the language of the text that is checked.protected StringgetDictFilenameInResources(String langCountry) private static StringgetDictionaryPath(String dicName, String originalPath) private List<RuleWithLanguage> getId()A string used to identify the rule in e.g.protected StringgetMessage(String origWord, SuggestedReplacement firstSuggestion) protected Stringprotected StringgetShortMessage(String origWord, SuggestedReplacement firstSuggestion) getSuggestions(String word) protected voidinit()private boolean(package private) booleanprotected booleanisInIgnoredSet(String word) booleanisMisspelled(String word) protected booleanisQuotedCompound(AnalyzedSentence analyzedSentence, int idx, String token) Is the given token part of a hyphenated compound preceded by a quoted token (e.g., „Spiegel“-Magazin) and should be treated as an ordinary hyphenated compound (e.g., „Spiegel-Magazin“)match(AnalyzedSentence sentence) Check whether the given sentence matches this error rule, i.e.private static PatternnonWordPatternFromPath(Path affPath) sortSuggestionByQuality(String misspelling, List<String> suggestions) protected String[]tokenizeText(String sentence) 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, ignoreWord, isDictionaryBasedSpellingRule, isEMail, isIgnoredNoCase, 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
-
RULE_ID
- See Also:
-
FILE_EXTENSION
- See Also:
-
needsInit
private volatile boolean needsInit -
hunspell
-
logger
private static final org.slf4j.Logger logger -
activeChecks
-
NON_ALPHABETIC
- See Also:
-
NON_ALPHABETIC_PATTERN
-
STARTS_WITH_TWO_UPPERCASE_CHARS
-
monitorRules
private static final boolean monitorRules -
commonPortugueseWords
-
commonGermanWords
-
MINUS_PLUS
-
ignoreFileContents
-
nonWordPatterns
-
WHITESPACE_ARRAY
-
nonWordPattern
-
userConfig
-
enSpellRules
-
-
Constructor Details
-
HunspellRule
-
HunspellRule
public HunspellRule(ResourceBundle messages, Language language, UserConfig userConfig, List<Language> altLanguages) - Since:
- 4.3
-
HunspellRule
public HunspellRule(ResourceBundle messages, Language language, UserConfig userConfig, List<Language> altLanguages, LanguageModel languageModel)
-
-
Method Details
-
getActiveChecks
-
getEnglishSpellingRules
-
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
-
isQuotedCompound
Is the given token part of a hyphenated compound preceded by a quoted token (e.g., „Spiegel“-Magazin) and should be treated as an ordinary hyphenated compound (e.g., „Spiegel-Magazin“) -
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
-
getMessage
-
getShortMessage
-
acceptSuggestion
-
isFirstItemHighConfidenceSuggestion
-
isEnglish
- Throws:
IOException
-
calcSuggestions
private List<SuggestedReplacement> calcSuggestions(String word, String cleanWord) throws IOException - Throws:
IOException
-
cutOffDot
-
isMisspelled
- Specified by:
isMisspelledin classSpellingCheckRule- Since:
- public since 4.1
-
getSuggestions
- Throws:
IOException
-
sortSuggestionByQuality
-
tokenizeText
-
getSentenceTextWithoutUrlsAndImmunizedTokens
-
ensureInitialized
- Throws:
IOException
-
init
- Overrides:
initin classSpellingCheckRule- Throws:
IOException
-
nonWordPatternFromPath
-
computeNonWordPattern
-
getDictFilenameInResources
-
addIgnoreWords
- Throws:
IOException
-
isInIgnoredSet
- Overrides:
isInIgnoredSetin classSpellingCheckRule
-
getDictionaryPath
- Throws:
IOException
-
fileCopy
- Throws:
IOException
-