LabeledBinaryExtractionWriter { public void writeExtraction(LabeledBinaryExtraction extr) throws IOException { ChunkedSentence sent = extr.getSentence(); out.println(sent.getTokensAsString()); out.println(sent.getPosTagsAsString()); out.println(sent.getChunkTagsAsString()); ChunkedArgumentExtraction arg1 = extr.getArgument1(); out.println(arg1.getTokensAsString()); out.println(arg1.getRange().getStart() + " " + arg1.getRange().getLength()); ChunkedExtraction rel = extr.getRelation(); out.println(rel.getTokensAsString()); out.println(rel.getRange().getStart() + " " + rel.getRange().getLength()); ChunkedArgumentExtraction arg2 = extr.getArgument2(); out.println(arg2.getTokensAsString()); out.println(arg2.getRange().getStart() + " " + arg2.getRange().getLength()); int label = extr.isPositive() ? 1 : 0; out.println(label); } LabeledBinaryExtractionWriter(OutputStream stream); void writeExtractions(Iterable<LabeledBinaryExtraction> extrs); void writeExtraction(LabeledBinaryExtraction extr);  }
@Test public void testWriteExtraction() throws Exception { String inputString = LabeledBinaryExtractionReaderTest.inputString; InputStream in = new ByteArrayInputStream(inputString.getBytes("UTF-8")); LabeledBinaryExtractionReader reader = new LabeledBinaryExtractionReader(in); Iterable<LabeledBinaryExtraction> extrs = reader.readExtractions(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); LabeledBinaryExtractionWriter writer = new LabeledBinaryExtractionWriter(baos); writer.writeExtractions(extrs); String result = baos.toString(); assertEquals(inputString, result); }