public BratDocument read() throws IOException { BratDocument doc = null; if (documentIdIterator.hasNext()) { String id = documentIdIterator.next(); try (InputStream txtIn = new BufferedInputStream(new FileInputStream(id + ".txt")); InputStream annIn = new BufferedInputStream(new FileInputStream(id + ".ann"))) { doc = BratDocument.parseDocument(config, id, txtIn, annIn); } } return doc; }
@Test public void testDocumentWithEntitiesParsing() throws IOException { Map<String, String> typeToClassMap = new HashMap<>(); BratAnnotationStreamTest.addEntityTypes(typeToClassMap); AnnotationConfiguration config = new AnnotationConfiguration(typeToClassMap); InputStream txtIn = BratDocumentTest.class.getResourceAsStream( "/opennlp/tools/formats/brat/voa-with-entities.txt"); InputStream annIn = BratDocumentTest.class.getResourceAsStream( "/opennlp/tools/formats/brat/voa-with-entities.ann"); BratDocument doc = BratDocument.parseDocument(config, "voa-with-entities", txtIn, annIn); Assert.assertEquals("voa-with-entities", doc.getId()); Assert.assertTrue(doc.getText().startsWith(" U . S . President ")); Assert.assertTrue(doc.getText().endsWith("multinational process . \n")); Assert.assertEquals(18, doc.getAnnotations().size()); BratAnnotation annotation = doc.getAnnotation("T2"); checkNote(annotation, "Barack Obama", "President Obama was the 44th U.S. president"); annotation = doc.getAnnotation("T3"); checkNote(annotation,"South Korea","The capital of South Korea is Seoul"); }
public BratDocument read() throws IOException { BratDocument doc = null; if (documentIdIterator.hasNext()) { String id = documentIdIterator.next(); try (InputStream txtIn = new BufferedInputStream(new FileInputStream(id + ".txt")); InputStream annIn = new BufferedInputStream(new FileInputStream(id + ".ann"))) { doc = BratDocument.parseDocument(config, id, txtIn, annIn); } } return doc; }
public BratDocument read() throws IOException { BratDocument doc = null; if (documentIdIterator.hasNext()) { String id = documentIdIterator.next(); try (InputStream txtIn = new BufferedInputStream(new FileInputStream(id + ".txt")); InputStream annIn = new BufferedInputStream(new FileInputStream(id + ".ann"))) { doc = BratDocument.parseDocument(config, id, txtIn, annIn); } } return doc; }
"/opennlp/tools/formats/brat/opennlp-1193.ann"); BratDocument doc = BratDocument.parseDocument(config, "opennlp-1193", txtIn, annIn);
"/opennlp/tools/formats/brat/opennlp-1193.ann"); BratDocument doc = BratDocument.parseDocument(config, "opennlp-1193", txtIn, annIn);