Package org.languagetool.rules.de
Class GermanSpellerRule
- Direct Known Subclasses:
AustrianGermanSpellerRule,SwissGermanSpellerRule
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate final GermanCompoundTokenizerprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate final LineExpanderprivate static final Patternprivate static final Patternprivate static final Patternprivate static final intprivate static final intprivate static final intprivate static final Patternprivate static final intprivate static final Patternprivate static final Patternprivate final GermanCompoundTokenizerprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternstatic final Stringprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final de.danielnaber.jwordsplitter.GermanWordSplitterprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate final Synthesizerprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final PatternFields inherited from class org.languagetool.rules.spelling.hunspell.HunspellRule
FILE_EXTENSION, hunspell, nonWordPatternFields inherited from class org.languagetool.rules.spelling.SpellingCheckRule
CUSTOM_SPELLING_FILE, GLOBAL_SPELLING_FILE, HIGH_CONFIDENCE, ignoreWordsWithLength, language, languageModel, LANGUAGETOOL, LANGUAGETOOLER, wordListLoader, wordsToBeIgnored -
Constructor Summary
ConstructorsConstructorDescriptionGermanSpellerRule(ResourceBundle messages, German language) GermanSpellerRule(ResourceBundle messages, German language, UserConfig userConfig, String languageVariantPlainTextDict) GermanSpellerRule(ResourceBundle messages, German language, UserConfig userConfig, String languageVariantPlainTextDict, List<Language> altLanguages, LanguageModel languageModel) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected voidaddIgnoreWords(String origLine) protected voidaddProhibitedWords(List<String> words) avoidInfixSAsSingleToken(List<String> parts) private Stringprivate booleancheckConfusionForPart1Part2Combination(String part1, String part2) private booleancheckInfixSForPart1Part2Combination(String part1, String part2) private booleancheckPluralForPart1Part2Combination(String part1, String part2) protected RuleMatchcreateWrongSplitMatch(AnalyzedSentence sentence, List<RuleMatch> ruleMatchesSoFar, int pos, String coveredWord, String suggestion1, String suggestion2, int prevPos) expandLine(String line) Expand suffixes in a line.protected voidfilterForLanguage(List<String> suggestions) protected List<SuggestedReplacement> private StringfindLemmaForNoun(String word) private Stringprotected List<SuggestedReplacement> getAdditionalTopSuggestions(List<SuggestedReplacement> suggestions, String word) Get additional suggestions added before other suggestions (note the rule may choose to re-order the suggestions anyway).getAdditionalTopSuggestionsString(List<String> suggestions, String word) getCandidates(String word) Find potential corrections - it's okay if some of these are not valid words, this list will be filtered against the spellchecker before being returned to the user.getFilteredSuggestions(List<String> wordsOrPhrases) getId()A string used to identify the rule in e.g.protected StringgetMessage(String origWord, SuggestedReplacement firstSuggestion) protected List<SuggestedReplacement> getOnlySuggestions(String word) Get suggestions that will replace all other suggestions.private StringgetParticipleForBaseform(String baseform) private Stringprivate Stringprotected static MorfologikMultiSpellergetSpeller(Language language, UserConfig userConfig, String languageVariantPlainTextDict) getSpellingFilePaths(String langCode) private static de.danielnaber.jwordsplitter.GermanWordSplittergetSuggestions(String word) As a hunspell-based approach is too slow, we use Morfologik to create suggestions.private Taggerprivate static BufferedReadergetVariantReader(String languageVariantPlainTextDict) private StringgetWordAfterEnumerationOrNull(List<String> words, int idx) private booleanignoreByHangingHyphen(List<String> words, int idx) private booleanprivate booleanignoreElative(String word) protected booleanLikeSpellingCheckRule.ignoreWord(String), but will only be called after the standard spell check has run and considered this word to be incorrect.protected booleanignoreWord(List<String> words, int idx) Returns true iff the word at the given position should be ignored by the spell checker.indexOfInfixS(List<String> parts) protected voidinit()private booleanisAdjBaseForm(String word) private booleanisAdjective(String word) private booleanisAdjOrNounOrUnknown(String word) private booleanprotected booleanisIgnoredNoCase(String word) booleanisMisspelled(String word) private booleanisNeedingFugenS(String word) private booleanprivate booleanprivate booleanisNounNomPlu(String word) private booleanisNounNomSin(String word) private booleanisNounOrProperNoun(String word) private booleanisNounOrUnknown(String word) private booleanisOldSpelling(List<String> parts) private booleanisOnlyNoun(String word) private booleanisOtherPrefix(String word) private booleanisProbablyTypo(String word) protected booleanisProhibited(String word) Whether the word is prohibited, i.e.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“)private booleanisSubVerInf(String word) private booleanisValidCamelCase(String input) private booleanisValidGenderNeutralWord(List<String> parts, String word) private booleanisValidPartLength(List<String> parts) private booleanisValidWordLength(String word) private booleanisVerbPrefix(String word) private booleanisVerbStem(String word) private voidmatch(AnalyzedSentence sentence) Check whether the given sentence matches this error rule, i.e.private booleanneedsInfixS(String word) private booleanneedsToBePlural(String lemma) protected booleanprocessThreePartCompound(List<String> parts) private booleanprocessTwoPartCompounds(String part1, String part2) private static voidprivate static voidprivate static voidprivate RuleMatch[]removeGenderCompoundMatches(AnalyzedSentence sentence, RuleMatch[] matches) private StringremoveTrailingHyphen(String part1) private StringremoveTrailingS(String part1) private StringremoveTrailingSAndHyphen(String part1) restoreRemovedHyphens(List<String> parts, String word) sortSuggestionByQuality(String misspelling, List<String> suggestions) splitPartsByHyphen(List<String> originalParts) Methods inherited from class org.languagetool.rules.spelling.hunspell.CompoundAwareHunspellRule
getCandidates, getStreamsMethods inherited from class org.languagetool.rules.spelling.hunspell.HunspellRule
ensureInitialized, getActiveChecks, getDescription, getDictFilenameInResources, getSentenceTextWithoutUrlsAndImmunizedTokens, getShortMessage, isInIgnoredSet, tokenizeTextMethods inherited from class org.languagetool.rules.spelling.SpellingCheckRule
acceptPhrases, addIgnoreTokens, addSuggestionsToRuleMatch, filterDupes, filterSuggestions, getAdditionalProhibitFileNames, getAdditionalSpellingFileNames, getAdditionalSuggestions, getAntiPatterns, getIgnoreFileName, getLanguageVariantSpellingFileName, getProhibitFileName, getSpellingFileName, ignoreToken, ignoreWord, isDictionaryBasedSpellingRule, isEMail, isLatinScript, 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:
-
MIN_WORD_LENGTH
private static final int MIN_WORD_LENGTH- See Also:
-
MAX_WORD_LENGTH
private static final int MAX_WORD_LENGTH- See Also:
-
MAX_EDIT_DISTANCE
private static final int MAX_EDIT_DISTANCE- See Also:
-
adjSuffix
- See Also:
-
missingAdjPattern
-
compoundPatternWithHeit
-
compoundPatternWithAction
-
compoundPatternWithFirst
-
compoundPatternSpecialEnding
-
lcDoNotSuggestWords
-
MAX_TOKEN_LENGTH
private static final int MAX_TOKEN_LENGTH- See Also:
-
GENDER_STAR_PATTERN
-
FILE_UNDERLINE_PATTERN
-
MENTION_UNDERLINE_PATTERN
-
FIRST_UPPER_CASE
-
HYPHENED_UPPER_WORD
-
HYPHENED_WORD
-
START_WITH_SPIEL
-
END_WITH_SCHAFTE
-
WORD_WITH_PUNCT
-
LOWER_CASE_WORD
-
SPECIAL_CASE
-
SPECIAL_CASE_WITH_S
-
AUTENTISCH_WITH_CASES
-
SYMPHATISCH
-
BRILLIANT_WITH_CASES
-
RECHTMASIG_WITH_CASES
-
HOLZ_SPIEGEL_PANEL_COMPOUND
-
SBHAN_PREFIX
-
UBAHN_PREFIX
-
SCHAF_PATTERN
-
SCHAFE_PATTERN
-
START_WITH_NEGER
-
CONTAINS_NEGER
-
CONTAINS_NEGER_2
-
CONTAINS_UNCOMMON_LOWERCASED_NOUN_AT_BEGINNING
-
CONTAINS_UNCOMMON_LOWERCASED_NOUN_AT_END
-
ENDS_WITH_IBELKEIT_IBLICHKEIT
-
ALLMAHLLIG
-
CONTAINS_MAYONNAISE
-
CONTAINS_MASZNAME
-
CONTAINS_RESERVIERUNG
-
STARTS_WITH_RESCHASCHIER
-
ENDS_WITH_LABORANTS
-
PROFESSIONELL
-
VERSTANDNIS
-
STARTS_WITH_DIAGNOSZIER
-
STARTING_WITH_SINGLE_CHAR
-
SPECIAL_CASE_THIRD
-
ZB
-
STARTS_WITH_ZB
-
DIRECTION
-
WOCHENTAGE
-
WOCHENTAGE_S
-
CAMEL_CASE
-
COMPOUND_TYPOS
-
COMPOUND_END_TYPOS
-
INFIX_S_SUFFIXES
-
WECHSELINFIX
-
CONFUSED_PREFIXES
-
NEEDS_TO_BE_PLURAL
-
SUBNOMPLUFEM_EXCEPTIONS
-
CITIES_EXCEPTIONS
-
INVALID_COMP_PART_1
-
INVALID_COMP_PART_2
-
SUBINF_SINGULAR_OBJECT
-
ARBEIT_COMP
-
BACH_COMP
-
BAD_COMP
-
LINK_COMP
-
LINKS_COMP
-
PERSON_SUFFIXES
-
RECHT_COMP
-
RECHTS_COMP
-
VERBAND_COMP
-
VERBANDS_COMP
-
WIDER_COMP
-
WOCHENTAG_COMP
-
POTENTIAL_BINNEN_I
-
GENDER_NEUTRAL_SPECIAL_CHRS_SIN
-
GENDER_NEUTRAL_SPECIAL_CHRS_PLU
-
GENDER_NEUTRAL_SLASH_HYPHEN
-
GENDER_STAR
-
GENDER2_STAR2
-
WECHSELNUMERUS
-
WELTEN_COMP
-
WOERTER_COMP
-
PREVENT_SUGGESTION_PATTERNS
-
EXPAND_PATTERN
-
wordsToBeIgnoredInCompounds
-
wordStartsToBeProhibited
-
wordEndingsToBeProhibited
-
wordsNeedingInfixS
-
verbStems
-
verbPrefixes
-
otherPrefixes
-
oldSpelling
-
ADDITIONAL_SUGGESTIONS
-
splitter
private static final de.danielnaber.jwordsplitter.GermanWordSplitter splitter -
lineExpander
-
compoundTokenizer
-
nonStrictCompoundTokenizer
-
synthesizer
-
-
Constructor Details
-
GermanSpellerRule
-
GermanSpellerRule
public GermanSpellerRule(ResourceBundle messages, German language, UserConfig userConfig, String languageVariantPlainTextDict) - Since:
- 4.2
-
GermanSpellerRule
public GermanSpellerRule(ResourceBundle messages, German language, UserConfig userConfig, String languageVariantPlainTextDict, List<Language> altLanguages, LanguageModel languageModel) - Since:
- 4.3
-
-
Method Details
-
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.- Overrides:
matchin classHunspellRule- Parameters:
sentence- a pre-analyzed sentence- Returns:
- an array of
RuleMatchobjects - Throws:
IOException
-
removeGenderCompoundMatches
@NotNull private RuleMatch[] removeGenderCompoundMatches(AnalyzedSentence sentence, RuleMatch[] matches) -
putRepl
-
put
-
put
-
getSplitter
private static de.danielnaber.jwordsplitter.GermanWordSplitter getSplitter() -
loadFile
-
init
- Overrides:
initin classHunspellRule- Throws:
IOException
-
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.- Overrides:
getIdin classHunspellRule
-
isIgnoredNoCase
- Overrides:
isIgnoredNoCasein classSpellingCheckRule
-
getMessage
- Overrides:
getMessagein classHunspellRule
-
getCandidates
Description copied from class:CompoundAwareHunspellRuleFind potential corrections - it's okay if some of these are not valid words, this list will be filtered against the spellchecker before being returned to the user.- Overrides:
getCandidatesin classCompoundAwareHunspellRule
-
isProhibited
Description copied from class:SpellingCheckRuleWhether the word is prohibited, i.e. whether it should be marked as a spelling error even if the spell checker would accept it. (This is useful to improve our spell checker without waiting for the upstream checker to be updated.)- Overrides:
isProhibitedin classSpellingCheckRule
-
addIgnoreWords
- Overrides:
addIgnoreWordsin classSpellingCheckRule- Parameters:
origLine- the line as read fromspelling.txt.
-
expandLine
Description copied from class:SpellingCheckRuleExpand suffixes in a line. By default, the line is not expanded. Implementations might e.g. turnbicycle/Sinto[bicycle, bicycles].- Overrides:
expandLinein classSpellingCheckRule
-
createWrongSplitMatch
protected RuleMatch createWrongSplitMatch(AnalyzedSentence sentence, List<RuleMatch> ruleMatchesSoFar, int pos, String coveredWord, String suggestion1, String suggestion2, int prevPos) - Overrides:
createWrongSplitMatchin classSpellingCheckRule
-
getSuggestions
Description copied from class:CompoundAwareHunspellRuleAs a hunspell-based approach is too slow, we use Morfologik to create suggestions. As this won't work for compounds not in the dictionary, we split the word and also get suggestions on the compound parts. In the end, all candidates are filtered against Hunspell again (which supports compounds).- Overrides:
getSuggestionsin classCompoundAwareHunspellRule- Throws:
IOException
-
acceptSuggestion
- Overrides:
acceptSuggestionin classHunspellRule
-
getSpellingFilePaths
-
getSpeller
@Nullable protected static MorfologikMultiSpeller getSpeller(Language language, UserConfig userConfig, String languageVariantPlainTextDict) -
getVariantReader
-
filterForLanguage
- Specified by:
filterForLanguagein classCompoundAwareHunspellRule
-
sortSuggestionByQuality
- Overrides:
sortSuggestionByQualityin classCompoundAwareHunspellRule
-
getFilteredSuggestions
- Overrides:
getFilteredSuggestionsin classCompoundAwareHunspellRule
-
isNounOrUnknown
-
isOnlyNoun
-
isAdjOrNounOrUnknown
-
isNounOrProperNoun
-
isSubVerInf
-
isAdjBaseForm
-
ignoreElative
-
isMisspelled
- Overrides:
isMisspelledin classHunspellRule
-
ignoreWord
Description copied from class:SpellingCheckRuleReturns true iff the word at the given position should be ignored by the spell checker. If possible, useSpellingCheckRule.ignoreToken(AnalyzedTokenReadings[], int)instead.- Overrides:
ignoreWordin classSpellingCheckRule- Throws:
IOException
-
ignorePotentiallyMisspelledWord
Description copied from class:SpellingCheckRuleLikeSpellingCheckRule.ignoreWord(String), but will only be called after the standard spell check has run and considered this word to be incorrect. This way, tests run here can be a bit more computationally expensive.- Overrides:
ignorePotentiallyMisspelledWordin classSpellingCheckRule- Throws:
IOException
-
isValidWordLength
-
isValidPartLength
-
isOldSpelling
-
isValidGenderNeutralWord
-
removeTrailingS
-
removeTrailingHyphen
-
removeTrailingSAndHyphen
-
isAdjective
- Throws:
IOException
-
isNoun
- Throws:
IOException
-
processTwoPartCompounds
- Throws:
IOException
-
processThreePartCompound
- Throws:
IOException
-
checkInfixSForPart1Part2Combination
- Throws:
IOException
-
checkConfusionForPart1Part2Combination
private boolean checkConfusionForPart1Part2Combination(String part1, String part2) throws IOException - Throws:
IOException
-
checkPluralForPart1Part2Combination
- Throws:
IOException
-
findLemmaForNoun
- Throws:
IOException
-
isProbablyTypo
-
isValidCamelCase
-
restoreRemovedHyphens
-
avoidInfixSAsSingleToken
-
splitPartsByHyphen
-
indexOfInfixS
-
needsInfixS
- Throws:
IOException
-
needsToBePlural
- Throws:
IOException
-
isNounNom
- Throws:
IOException
-
isNounNomSin
- Throws:
IOException
-
isNounNomPlu
- Throws:
IOException
-
isCountryOrRegionNomSin
- Throws:
IOException
-
isOtherPrefix
- Throws:
IOException
-
isVerbPrefix
- Throws:
IOException
-
isVerbStem
- Throws:
IOException
-
getAdditionalTopSuggestions
protected List<SuggestedReplacement> getAdditionalTopSuggestions(List<SuggestedReplacement> suggestions, String word) throws IOException Description copied from class:SpellingCheckRuleGet additional suggestions added before other suggestions (note the rule may choose to re-order the suggestions anyway). Only add suggestions here that you know are spelled correctly, they will not be checked again before being shown to the user.- Overrides:
getAdditionalTopSuggestionsin classSpellingCheckRule- Throws:
IOException
-
getAdditionalTopSuggestionsString
private List<String> getAdditionalTopSuggestionsString(List<String> suggestions, String word) throws IOException - Throws:
IOException
-
getPastTenseVerbSuggestion
-
baseForThirdPersonSingularVerb
- Throws:
IOException
-
getParticipleSuggestion
-
getParticipleForBaseform
- Throws:
IOException
-
getAbbreviationSuggestion
- Throws:
IOException
-
ignoreByHangingHyphen
- Throws:
IOException
-
isNeedingFugenS
-
getWordAfterEnumerationOrNull
-
ignoreCompoundWithIgnoredWord
- Throws:
IOException
-
getTagger
-
isQuotedCompound
Description copied from class:HunspellRuleIs 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“)- Overrides:
isQuotedCompoundin classHunspellRule
-
addProhibitedWords
- Overrides:
addProhibitedWordsin classSpellingCheckRule- Parameters:
words- list of words to be prohibited.
-
filterNoSuggestWords
- Overrides:
filterNoSuggestWordsin classSpellingCheckRule
-
getOnlySuggestions
Description copied from class:SpellingCheckRuleGet suggestions that will replace all other suggestions. Only add suggestions here that you know are spelled correctly, they will not be checked again before being shown to the user.- Overrides:
getOnlySuggestionsin classSpellingCheckRule
-