class IsEnglishWordFilter extends RuleFilter {

  private Language english = null;
  //private SpellingCheckRule spellingCheckRule = null;
  private Tagger tagger = null;

  public IsEnglishWordFilter() {
    try {
      english = Languages.getLanguageForShortCode("en-US");
    } catch (Exception e) {
    }
    if (english != null) {
      //spellingCheckRule = english.getDefaultSpellingRule();
      tagger = english.createDefaultTagger();
    }
  }

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

  private boolean wordIsTaggedWith(String word, String postag) throws IOException {
    return tagger.tag(Collections.singletonList(word)).get(0).matchesPosTagRegex(postag);
  }

  private boolean wordIsTagged(String word) throws IOException {
    return tagger.tag(Collections.singletonList(word)).get(0).isTagged();
  }

}


    if (tagger == null) {
      return null;
    }
    String[] formPositions = getRequired("formPositions", args).split(",");
    List<String> forms = new ArrayList<>();
    for (String formPosition : formPositions) {
      forms.add(patternTokens[getSkipCorrectedReference(tokenPositions, Integer.parseInt(formPosition))].getToken());
    }
    boolean isEnglish = true;
    String postagsStr = getOptional("postags", args);
    if (postagsStr != null) {
      String [] postags = postagsStr.split(",");
      if (postags.length != forms.size()) {
        throw new RuntimeException("The number of forms and postags has to be the same in disambiguation rule with " +
            "filter IsEnglishWordFilter.");
      }
      for (int i = 0; i < postags.length; i++) {
        isEnglish = isEnglish && wordIsTaggedWith(forms.get(i), postags[i]);
      }
    } else {
      for (int i = 0; i < forms.size(); i++) {
        isEnglish = isEnglish && wordIsTagged(forms.get(i));
      }
    }
    return (isEnglish ? match : null);
  
<methods>public non-sealed void <init>() ,public abstract org.languagetool.rules.RuleMatch acceptRuleMatch(org.languagetool.rules.RuleMatch, Map<java.lang.String,java.lang.String>, int, org.languagetool.AnalyzedTokenReadings[], List<java.lang.Integer>) throws java.io.IOException,public boolean matches(Map<java.lang.String,java.lang.String>, org.languagetool.AnalyzedTokenReadings[], int, List<java.lang.Integer>) throws java.io.IOException<variables>