System.out.println("Training:");
System.out.println(StringUtils.join(test.trainCommandLine));
ByteArrayOutputStream savedOutput = new ByteArrayOutputStream();
TeeStream teeOut = new TeeStream(savedOutput, System.out);
PrintStream teeOutPS = new PrintStream(teeOut);
TeeStream teeErr = new TeeStream(savedOutput, System.err);
PrintStream teeErrPS = new PrintStream(teeErr);
System.setOut(teeOutPS);
System.setErr(teeErrPS);
LexicalizedParser.main(test.trainCommandLine);
teeOutPS.flush();
teeErrPS.flush();
teeOut.flush();
teeErr.flush();
String[] outputLines =
savedOutput.toString().split("(?:\\n|\\r)+");
String perfLine = outputLines[outputLines.length - 5];
System.out.println(perfLine);
assertEquals("factor LP/LR summary evalb: LP: 100.0 LR: 100.0 F1: 100.0 Exact: 100.0 N: 1", perfLine.trim());
Formatter commandLineFormatter = new Formatter();
commandLineFormatter.format(baseTestSerCommandLine,
test.parserFile.getPath(), test.testPath);
String[] testCommandLine =
commandLineFormatter.toString().split("\\s");
System.out.println("Testing:");
System.out.println(StringUtils.join(testCommandLine));
LexicalizedParser.main(testCommandLine);
commandLineFormatter = new Formatter();
commandLineFormatter.format(baseTestTextCommandLine,
test.textFile.getPath(), test.testPath);
testCommandLine = commandLineFormatter.toString().split("\\s");
System.out.println("Testing:");
System.out.println(StringUtils.join(testCommandLine));
LexicalizedParser.main(testCommandLine);
teeOutPS.flush();
teeErrPS.flush();
teeOut.flush();
teeErr.flush();
System.setOut(originalOut);
System.setErr(originalErr);
}