Class RuleFilter

java.lang.Object
org.languagetool.rules.patterns.RuleFilter
Direct Known Subclasses:
AbstractDateCheckFilter, AbstractFutureDateFilter, AbstractNewYearDateFilter, DateRangeChecker, PartialPosTagFilter, ShortenedYearRangeChecker, WhitespaceCheckFilter

public abstract class RuleFilter extends Object
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)
  • Constructor Details

    • RuleFilter

      public RuleFilter()
  • Method Details

    • acceptRuleMatch

      @Nullable public abstract @Nullable RuleMatch acceptRuleMatch(RuleMatch match, Map<String,String> arguments, int patternTokenPos, AnalyzedTokenReadings[] patternTokens)
      Returns the original rule match or a modified one, or null if the rule match is filtered out.
      Parameters:
      arguments - the resolved argument from the args attribute in the XML. Resolved means that e.g. \1 has been resolved to the actual string at that match position.
      patternTokens - those tokens of the text that correspond the matched pattern
      Returns:
      null if this rule match should be removed, or any other RuleMatch (e.g. the one from the arguments) that properly describes the detected error
    • matches

      public boolean matches(Map<String,String> arguments, AnalyzedTokenReadings[] patternTokens, int firstMatchToken)
      Since:
      3.2
    • getRequired

      protected String getRequired(String key, Map<String,String> map)