class BrazilianToponymFilter extends RegexRuleFilter {
  private static final BrazilianToponymMap map = new BrazilianToponymMap();

  @Override
  public RuleMatch acceptRuleMatch(RuleMatch match, Map<String, String> arguments, AnalyzedSentence sentence, Matcher matcher) {<FILL_FUNCTION_BODY>}
}

    String toponym = matcher.group(1);
    String underlined = matcher.group(2);
    String state = matcher.group(3);

    // TODO: read this from user options or something...
    String suggestion = "–" + state;
    if (suggestion.equals(underlined)) {
      return null;
    }
    // If it isn't a city in *any* state, it's prob. not intended as a city, so we don't perform the check.
    if (!map.isValidToponym(toponym)) {
      return null;
    }
    match.setSuggestedReplacement(suggestion);
    return match;
  
<methods>public non-sealed void <init>() ,public abstract org.languagetool.rules.RuleMatch acceptRuleMatch(org.languagetool.rules.RuleMatch, Map<java.lang.String,java.lang.String>, org.languagetool.AnalyzedSentence, java.util.regex.Matcher) <variables>