class LanguageToolEvaluator implements Evaluator {

  private final JLanguageTool lt;
  private final LanguageModel languageModel;

  LanguageToolEvaluator(File indexTopDir) throws IOException {
    lt = new JLanguageTool(new BritishEnglish());
    disableRules();
    if (indexTopDir != null) {
      if (indexTopDir.isDirectory()) {
        languageModel = new LuceneLanguageModel(indexTopDir);
        System.out.println("Using Lucene language model from " + languageModel);
        EnglishConfusionProbabilityRule probabilityRule =
                new EnglishConfusionProbabilityRule(JLanguageTool.getMessageBundle(), languageModel, new English());
        //new EnglishConfusionProbabilityRule(JLanguageTool.getMessageBundle(), languageModel, new File("/tmp/languagetool_network.net"));
        lt.addRule(probabilityRule);
      } else {
        throw new RuntimeException("Does not exist or not a directory: " + indexTopDir);
      }
    } else {
      languageModel = null;
    }
  }
  
  @Override
  public void close() {
    if (languageModel != null) {
      languageModel.close();
    }
  }

  private void disableRules() {<FILL_FUNCTION_BODY>}

  @Override
  public List<RuleMatch> check(AnnotatedText annotatedText) throws IOException {
    return lt.check(annotatedText);
  }
}

    // The Pedler corpus has some real errors that have no error markup, so we disable
    // some rules that typically match those:
    lt.disableRule("COMMA_PARENTHESIS_WHITESPACE");
    lt.disableRule("SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA");
    lt.disableRule("EN_QUOTES");
    lt.disableRule("I_LOWERCASE");
    //langTool.disableRule("MORFOLOGIK_RULE_EN_GB");  // disabling spell rule improves precision 0.77 -> 0.88 (as of 2014-07-18)
    // turn off style rules:
    lt.disableRule("LITTLE_BIT");
    lt.disableRule("ALL_OF_THE");
    lt.disableRule("SOME_OF_THE");
    // British English vs. American English - not clear whether the corpus contains only BE:
    lt.disableRule("EN_GB_SIMPLE_REPLACE");
    lt.disableRule("APARTMENT-FLAT");
  
<no_super_class>