@@ -0,0 +1,1645 @@
+package org.antlr.codebuff.validation;%0A%0Aimport org.antlr.codebuff.Corpus;%0Aimport org.antlr.codebuff.Formatter;%0Aimport org.antlr.codebuff.InputDocument;%0Aimport org.antlr.codebuff.Tool;%0Aimport org.antlr.codebuff.misc.LangDescriptor;%0A%0Aimport java.io.File;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Aimport static org.antlr.codebuff.Tool.languages;%0Aimport static org.antlr.codebuff.Tool.levenshteinDistance;%0Aimport static org.antlr.codebuff.misc.BuffUtils.map;%0A%0Apublic class OneFileCapture %7B%0A%0A%09public static String testAllLanguages(LangDescriptor%5B%5D languages, String%5B%5D corpusDirs) throws Exception %7B%0A%09%09List%3CString%3E languageNames = map(languages, l -%3E l.name);%0A%09%09Map%3CString, Integer%3E corpusSizes = new HashMap%3C%3E();%0A%09%09for (int i = 0; i%3Clanguages.length; i++) %7B%0A%09%09%09LangDescriptor language = languages%5Bi%5D;%0A%09%09%09List%3CString%3E filenames = Tool.getFilenames(new File(corpusDirs%5Bi%5D), language.fileRegex);%0A%09%09%09for (String fileName : filenames) %7B%0A%09%09%09%09corpusSizes.put(language.name, filenames.size());%0A%09%09%09%09Corpus corpus = new Corpus(fileName, Tool.ANTLR4_DESCR);%0A%09%09%09%09corpus.train();%0A%09%09%09%09InputDocument testDoc = Tool.load(fileName, corpus.language);%0A%09%09%09%09Formatter formatter = new Formatter(corpus);%0A%09%09%09%09String output = formatter.format(testDoc, false);%0A%09%09%09%09float editDistance = levenshteinDistance(testDoc.content, output);%0A%09%09%09%09System.out.println(%22edit distance %22+editDistance);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return %22%22;%0A%09%7D%0A%0A%09public static void main(String%5B%5D args) throws Exception %7B%0A%09%09List%3CString%3E corpusDirs = map(languages, l -%3E l.corpusDir);%0A%09%09String%5B%5D dirs = corpusDirs.toArray(new String%5Blanguages.length%5D);%0A%09%09testAllLanguages(languages, dirs);%0A%09%7D%0A%7D%0A

add kernel of one-file-capture