public static void format(LangDescriptor language,
String testFileName,
String outputFileName)
throws Exception
{
// load all files up front
List<String> allFiles = getFilenames(new File(language.corpusDir), language.fileRegex);
List<InputDocument> documents = load(allFiles, language);
// if in corpus, don't include in corpus
final String path = new File(testFileName).getAbsolutePath();
List<InputDocument> others = filter(documents, d -> !d.fileName.equals(path));
InputDocument testDoc = parse(testFileName, language);
Corpus corpus = new Corpus(others, language);
corpus.train();
Formatter formatter = new Formatter(corpus, language.indentSize, Formatter.DEFAULT_K,
FEATURES_INJECT_WS, FEATURES_HPOS);
String output = formatter.format(testDoc, false);
if ( outputFileName!=null ) {
Utils.writeFile(outputFileName, output);
}
else {
System.out.print(output);
}
}
Tool.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:codebuff
作者:
评论列表
文章目录