Examples of TeeStream


Examples of edu.stanford.nlp.io.TeeStream

    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);
  }
View Full Code Here

Examples of edu.stanford.nlp.io.TeeStream

      command.add(in + "/timex-attributes.tab");
      command.add(out + "/timex-attrs.res.tab");
      ProcessBuilder pb = new ProcessBuilder(command);
      FileOutputStream evalFileOutput = new FileOutputStream(out + "/scores.txt");
      Writer output = new OutputStreamWriter(
              new TeeStream(System.out, evalFileOutput));
      SystemUtils.run(pb, output, null);
      evalFileOutput.close();
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.