Package org.languagetool.rules.patterns
Class RuleFilter
java.lang.Object
org.languagetool.rules.patterns.RuleFilter
- Direct Known Subclasses:
AbstractAdvancedSynthesizerFilter,AbstractDateCheckFilter,AbstractDateCheckWithSuggestionsFilter,AbstractFindSuggestionsFilter,AbstractFutureDateFilter,AbstractMakeContractionsFilter,AbstractNewYearDateFilter,AbstractNumberInWordFilter,AbstractSuppressMisspelledSuggestionsFilter,AbstractTextToNumberFilter,AdaptSuggestionFilter,AdaptSuggestionsFilter,AddCommasFilter,AdjustPronounsFilter,AdjustVerbSuggestionsFilter,AdverbFilter,AnarASuggestionsFilter,ApostropheTypeFilter,ArabicAdjectiveToExclamationFilter,ArabicMasdarToVerbFilter,ArabicNumberPhraseFilter,ArabicVerbToMafoulMutlaqFilter,CatalanNumberSpellerFilter,CheckPostagsInSuggestionFilter,CompoundCheckFilter,CompoundFilter,ConfusionCheckFilter,ConfusionCheckFilter,ConvertToGenderAndNumberFilter,ConvertToSentenceCaseFilter,DateRangeChecker,DecadeSpellingFilter,DiacriticsCheckFilter,DonarTempsSuggestionsFilter,INNNumberFilter,InsertCommaFilter,InterrogativeVerbFilter,IsEnglishWordFilter,MultitokenSpellerFilter,OblidarseSugestionsFilter,OrdinalSuffixFilter,PartialPosTagFilter,PortarGerundiSuggestionsFilter,PortarTempsSuggestionsFilter,PortugueseEnclisisFilter,PortugueseProclisisFilter,PossessiusRedundantsFilter,PostponedAdjectiveConcordanceFilter,PostponedAdjectiveConcordanceFilter,PostponedAdjectiveConcordanceFilter,PotentialCompoundFilter,RecentYearFilter,RegularIrregularParticipleFilter,RemoveUnknownCompoundsFilter,RomanNumeralFilter,ShortenedYearRangeChecker,SuggestionsFilter,SuppressIfAnyRuleMatchesFilter,SynthesizeWithDeterminerFilter,UnderlineSpacesFilter,UppercaseNounReadingFilter,ValidWordFilter,WhitespaceCheckFilter,WordWithDeterminerFilter
Filter rule matches after a PatternRule has matched already.
Can be used from the XML using the
filter element.- Since:
- 2.7 (changed from interface to abstract class in 3.2)
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract RuleMatchacceptRuleMatch(RuleMatch match, Map<String, String> arguments, int patternTokenPos, AnalyzedTokenReadings[] patternTokens, List<Integer> tokenPositions) Returns the original rule match or a modified one, ornullif the rule match is filtered out.protected StringgetOptional(String key, Map<String, String> map) protected Stringprotected intgetPosition(String fromStr, AnalyzedTokenReadings[] patternTokens, RuleMatch match) protected StringgetRequired(String key, Map<String, String> map) protected intgetSkipCorrectedReference(List<Integer> tokenPositions, int refNumber) protected booleanisMatchAtSentenceStart(AnalyzedTokenReadings[] tokens, RuleMatch match) booleanmatches(Map<String, String> arguments, AnalyzedTokenReadings[] patternTokens, int firstMatchToken, List<Integer> tokenPositions)
-
Constructor Details
-
RuleFilter
public RuleFilter()
-
-
Method Details
-
acceptRuleMatch
@Nullable public abstract RuleMatch acceptRuleMatch(RuleMatch match, Map<String, String> arguments, int patternTokenPos, AnalyzedTokenReadings[] patternTokens, List<Integer> tokenPositions) throws IOExceptionReturns the original rule match or a modified one, ornullif the rule match is filtered out.- Parameters:
arguments- the resolved argument from theargsattribute in the XML. Resolved means that e.g.\1has been resolved to the actual string at that match position.patternTokens- those tokens of the text that correspond the matched pattern- Returns:
nullif this rule match should be removed, or any other RuleMatch (e.g. the one from the arguments) that properly describes the detected error- Throws:
IOException
-
matches
public boolean matches(Map<String, String> arguments, AnalyzedTokenReadings[] patternTokens, int firstMatchToken, List<Integer> tokenPositions) throws IOException- Throws:
IOException- Since:
- 3.2
-
getRequired
-
getOptional
-
getOptional
-
getPosition
-
isMatchAtSentenceStart
-
getSkipCorrectedReference
-
getLanguageFromRuleMatch
-
getSynthesizerFromRuleMatch
-