ADPOSSampleStream implements ObjectStream<POSSample> { public POSSample read() throws IOException { Sentence paragraph; while ((paragraph = this.adSentenceStream.read()) != null) { Node root = paragraph.getRoot(); List<String> sentence = new ArrayList<String>(); List<String> tags = new ArrayList<String>(); process(root, sentence, tags); return new POSSample(sentence, tags); } return null; } ADPOSSampleStream(ObjectStream<String> lineStream, boolean expandME,
      boolean includeFeatures);  ADPOSSampleStream(InputStream in, String charsetName,
      boolean expandME, boolean includeFeatures); POSSample read(); void reset(); void close();  }
@Test public void testSimple() throws IOException { ADPOSSampleStream stream = new ADPOSSampleStream( new PlainTextByLineStream( ADParagraphStreamTest.class .getResourceAsStream("/opennlp/tools/formats/ad.sample"), "UTF-8"), false, false); POSSample sample = stream.read(); assertEquals(23, sample.getSentence().length); assertEquals("Inicia", sample.getSentence()[0]); assertEquals("v-fin", sample.getTags()[0]); assertEquals("em", sample.getSentence()[1]); assertEquals("prp", sample.getTags()[1]); assertEquals("o", sample.getSentence()[2]); assertEquals("art", sample.getTags()[2]); assertEquals("Porto_Poesia", sample.getSentence()[9]); assertEquals("prop", sample.getTags()[9]); }
@Test public void testExpandME() throws IOException { ADPOSSampleStream stream = new ADPOSSampleStream( new PlainTextByLineStream( ADParagraphStreamTest.class .getResourceAsStream("/opennlp/tools/formats/ad.sample"), "UTF-8"), true, false); POSSample sample = stream.read(); assertEquals(27, sample.getSentence().length); assertEquals("Inicia", sample.getSentence()[0]); assertEquals("v-fin", sample.getTags()[0]); assertEquals("em", sample.getSentence()[1]); assertEquals("prp", sample.getTags()[1]); assertEquals("o", sample.getSentence()[2]); assertEquals("art", sample.getTags()[2]); assertEquals("Porto", sample.getSentence()[9]); assertEquals("B-prop", sample.getTags()[9]); assertEquals("Poesia", sample.getSentence()[10]); assertEquals("I-prop", sample.getTags()[10]); }
@Test public void testIncludeFeats() throws IOException { ADPOSSampleStream stream = new ADPOSSampleStream( new PlainTextByLineStream( ADParagraphStreamTest.class .getResourceAsStream("/opennlp/tools/formats/ad.sample"), "UTF-8"), false, true); POSSample sample = stream.read(); assertEquals(23, sample.getSentence().length); assertEquals("Inicia", sample.getSentence()[0]); assertEquals("v-fin=PR=3S=IND=VFIN", sample.getTags()[0]); assertEquals("em", sample.getSentence()[1]); assertEquals("prp", sample.getTags()[1]); assertEquals("o", sample.getSentence()[2]); assertEquals("art=DET=M=S", sample.getTags()[2]); assertEquals("Porto_Poesia", sample.getSentence()[9]); assertEquals("prop=M=S", sample.getTags()[9]); }