class LuceneLanguageModel extends BaseLanguageModel {

  private final List<LuceneSingleIndexLanguageModel> lms = new ArrayList<>();

  public static void validateDirectory(File topIndexDir) {<FILL_FUNCTION_BODY>}

  @Nullable
  private static File[] getSubDirectoriesOrNull(File topIndexDir) {
    return topIndexDir.listFiles((file, name) -> name.matches("index-\\d+"));
  }

  /**
   * @param topIndexDir a directory which contains either:
   *                    1) sub directories called {@code 1grams}, {@code 2grams}, {@code 3grams},
   *                    which are Lucene indexes with ngram occurrences as created by
   *                    {@code org.languagetool.dev.FrequencyIndexCreator}
   *                    or 2) sub directories {@code index-1}, {@code index-2} etc that contain
   *                    the sub directories described under 1)
   */
  public LuceneLanguageModel(File topIndexDir)  {
    File[] subDirs = getSubDirectoriesOrNull(topIndexDir);
    if (subDirs != null && subDirs.length > 0) {
      System.out.println("Running in multi-index mode with " + subDirs.length + " indexes: " + topIndexDir);
      for (File subDir : subDirs) {
        lms.add(new LuceneSingleIndexLanguageModel(subDir));
      }
    } else {
      lms.add(new LuceneSingleIndexLanguageModel(topIndexDir));
    }
  }

  @Override
  public long getCount(List<String> tokens) {
    return lms.stream().mapToLong(lm -> lm.getCount(tokens)).sum();
  }

  @Override
  public long getCount(String token) {
    return getCount(Arrays.asList(token));
  }

  @Override
  public long getTotalTokenCount() {
    return lms.stream().mapToLong(lm -> lm.getTotalTokenCount()).sum();
  }

  @Override
  public void close() {
    lms.forEach(lm -> lm.close());
  }

  @Override
  public String toString() {
    return lms.toString();
  }

}

    File[] subDirs = getSubDirectoriesOrNull(topIndexDir);
    if (subDirs == null || subDirs.length == 0) {
      LuceneSingleIndexLanguageModel.validateDirectory(topIndexDir);
    }
  
<methods>public void <init>() ,public abstract long getCount(java.lang.String) ,public abstract long getCount(List<java.lang.String>) ,public org.languagetool.rules.ngrams.Probability getPseudoProbability(List<java.lang.String>) ,public org.languagetool.rules.ngrams.Probability getPseudoProbabilityStupidBackoff(List<java.lang.String>) ,public abstract long getTotalTokenCount() <variables>private static final boolean DEBUG,private java.lang.Long totalTokenCount