* @param outputDir the directory to save normalized tree files.
* @param extension the tree file extension (e.g., {@code parse}).
*/
public void run(String inputDir, String outputDir, String extension)
{
CTReader reader;
CTTree tree;
PrintStream fout;
StringBuilder build;
File dir = new File(outputDir);
if (!dir.exists()) dir.mkdirs();
inputDir += File.separator;
outputDir += File.separator;
for (String filename : new File(inputDir).list(new FileExtFilter(extension)))
{
reader = new CTReader(UTInput.createBufferedFileReader(inputDir + filename));
fout = UTOutput.createPrintBufferedFileStream(outputDir + filename);
while ((tree = reader.nextTree()) != null)
{
/* build = new StringBuilder();
for (CTNode node : tree.getTokens())
{
build.append(" ");
build.append(node.form);
build.append("/");
build.append(node.pTag);
}
fout.println(build.substring(1));*/
for (CTNode node : tree.getTokens())
{
build = new StringBuilder();
build.append(node.form);
build.append(AbstractColumnReader.DELIM_COLUMN);
build.append(node.pTag);
fout.println(build.toString());
}
fout.println();
}
reader.close();
fout.close();
}
}