class FindSuggestionsEsFilter extends FindSuggestionsFilter {

  // es + unknown -> és + noun/adj | es + verb 3rd person

  Pattern pApostropheNeeded = Pattern.compile("h?[aeiouàèéíòóú].*", Pattern.CASE_INSENSITIVE);

  public FindSuggestionsEsFilter() throws IOException {
    // lazy init
    if (speller == null) {
      if (JLanguageTool.getDataBroker().resourceExists(DICT_FILENAME)) {
        speller = new MorfologikSpeller(DICT_FILENAME);
      }
    }
  }

  @Override
  public RuleMatch acceptRuleMatch(RuleMatch match, Map<String, String> arguments, int patternTokenPos,
                                   AnalyzedTokenReadings[] patternTokens, List<Integer> tokenPositions) throws IOException {<FILL_FUNCTION_BODY>}

}


    List<String> replacements = new ArrayList<>();
    int posWord = 0;
    while (posWord < patternTokens.length
        && (patternTokens[posWord].getStartPos() < match.getFromPos() || patternTokens[posWord].isSentenceStart())) {
      posWord++;
    }
    posWord++;
    AnalyzedTokenReadings atrWord = patternTokens[posWord];
    List<String> suggestions = getSpellingSuggestions(atrWord);
    boolean usedEsAccent = false;
    boolean usedEs = false;
    if (suggestions.size() > 0) {
      for (String suggestion : suggestions) {
        // TODO: do not tag capitalized words with tags for lower case
        List<AnalyzedTokenReadings> analyzedSuggestions = getTagger()
            .tag(Collections.singletonList(cleanSuggestion(suggestion)));
        for (AnalyzedTokenReadings analyzedSuggestion : analyzedSuggestions) {
          if (replacements.size() >= 2 * MAX_SUGGESTIONS) {
            break;
          }
          if (analyzedSuggestion.matchesPosTagRegex("NP.*|NC.[SN].*|A...[SN].|V.P..S..|V.[NG].*|RG|PX..S...")) {
            replacements.add("és " + analyzedSuggestion.getToken());
            usedEsAccent = true;
          }
          if (analyzedSuggestion.matchesPosTagRegex("V...3.*")) {
            Matcher m = pApostropheNeeded.matcher(analyzedSuggestion.getToken());
            if (!m.matches()) {
              replacements.add("es " + analyzedSuggestion.getToken().toLowerCase());
              usedEs = true;
            }
          }
        }
      }
    }
    if (replacements.isEmpty()) {
      return null;
    }

    List<String> definitiveReplacements = new ArrayList<>();
    String firstCh = patternTokens[posWord - 1].getToken().substring(0, 1);
    if (firstCh.toUpperCase().equals(firstCh)) {
      for (String r : replacements) {
        definitiveReplacements.add(StringTools.uppercaseFirstChar(r));
      }
    } else {
      definitiveReplacements.addAll(replacements);
    }
    boolean isFirstEsAccent = patternTokens[posWord - 1].getToken().equalsIgnoreCase("és");
    String message = match.getMessage();
    
    
    if (isFirstEsAccent && usedEsAccent && !usedEs) {
      // show just the spelling rule;
      return null;
    }
//    if (!isFirstEsAccent && !usedEsAccent && usedEs) {
//      // show just the spelling rule;
//      return null;
//    }  
    if (usedEsAccent) {
      message = message + " \"És\" (del v. 'ser') s'escriu amb accent.";
    }
    if (usedEs) {
      message = message + " \"Es\" (pronom) acompanya un verb en tercera persona.";
    }
    RuleMatch ruleMatch = new RuleMatch(match.getRule(), match.getSentence(), match.getFromPos(), match.getToPos(),
        message, match.getShortMessage());
    ruleMatch.setType(match.getType());
    ruleMatch.setSuggestedReplacements(definitiveReplacements);
    return ruleMatch;
  
<methods>public void <init>() throws java.io.IOException<variables>protected static final java.lang.String DICT_FILENAME,public static final java.lang.String[] LemmasToAllow,public static final java.lang.String[] LemmasToIgnore,protected static org.languagetool.rules.spelling.morfologik.MorfologikSpeller speller