class NeededNGramCounter {

  private static final String LANG = "en";

  private NeededNGramCounter() {
  }

  public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}
  
}

    if (args.length != 1) {
      System.out.println("Usage: " + NeededNGramCounter.class.getSimpleName() + " <ngramIndexDir>");
      System.exit(1);
    }
    Language lang = Languages.getLanguageForShortCode(LANG);
    String path = "/" + lang.getShortCode() + "/confusion_sets.txt";
    Set<String> ngrams;
    try (InputStream confSetStream = JLanguageTool.getDataBroker().getFromResourceDirAsStream(path)) {
      ngrams = new ConfusionSetLoader(new AmericanEnglish()).loadConfusionPairs(confSetStream).keySet();
    }
    String ngramIndexDir = args[0];
    FSDirectory fsDir = FSDirectory.open(new File(ngramIndexDir).toPath());
    IndexReader reader = DirectoryReader.open(fsDir);
    Fields fields = MultiFields.getFields(reader);
    Terms terms = fields.terms("ngram");
    TermsEnum termsEnum = terms.iterator();
    int i = 0;
    int needed = 0;
    int notNeeded = 0;
    BytesRef next;
    while ((next = termsEnum.next()) != null) {
      String term = next.utf8ToString();
      String[] tmpTerms = term.split(" ");
      boolean ngramNeeded = false;
      for (String tmpTerm : tmpTerms) {
        if (ngrams.contains(tmpTerm)) {
          ngramNeeded = true;
          break;
        }
      }
      if (ngramNeeded) {
        //System.out.println("needed: " + term);
        needed++;
      } else {
        //System.out.println("not needed: " + term);
        notNeeded++;
      }
      if (i % 500_000 == 0) {
        System.out.println(i + "/" + terms.getDocCount());
      }
      i++;
    }
    System.out.println("language         : " + LANG);
    System.out.println("ngram index      : " + ngramIndexDir);
    System.out.println("needed ngrams    : " + needed);
    System.out.println("not needed ngrams: " + notNeeded);
  
<no_super_class>