Re3dReader extends BaleenCollectionReader { @Override public boolean doHasNext() throws IOException, CollectionException { return !documents.isEmpty(); }  @Override boolean doHasNext(); static final String PARAM_FOLDER; static final String PARAM_ENTITIES; static final String PARAM_RELATIONSHIPS; static final String PARAM_RANDOM_DATES; }
@Test public void testDocumentText() throws Exception { BaleenCollectionReader bcr = getCollectionReader( Re3dReader.PARAM_FOLDER, tmpDir.toAbsolutePath().toString(), Re3dReader.PARAM_ENTITIES, true, Re3dReader.PARAM_RANDOM_DATES, true); assertTrue(bcr.doHasNext()); bcr.getNext(jCas.getCas()); assertTrue(jCas.getDocumentText().contains("This is the text of the article.")); bcr.close(); }
@Test public void testDocumentMetadata() throws Exception { BaleenCollectionReader bcr = getCollectionReader( Re3dReader.PARAM_FOLDER, tmpDir.toAbsolutePath().toString(), Re3dReader.PARAM_ENTITIES, true, Re3dReader.PARAM_RANDOM_DATES, true); assertTrue(bcr.doHasNext()); bcr.getNext(jCas.getCas()); AnnotationIndex<DocumentAnnotation> annotationIndex = jCas.getAnnotationIndex(DocumentAnnotation.class); assertTrue(contains(annotationIndex, d -> d.getSourceUri().equals(SOURCE_URL))); bcr.close(); }
@Test public void testEntities() throws Exception { BaleenCollectionReader bcr = getCollectionReader( Re3dReader.PARAM_FOLDER, tmpDir.toAbsolutePath().toString(), Re3dReader.PARAM_ENTITIES, true, Re3dReader.PARAM_RANDOM_DATES, true); assertTrue(bcr.doHasNext()); bcr.getNext(jCas.getCas()); AnnotationIndex<Entity> annotationIndex = jCas.getAnnotationIndex(Entity.class); contains(annotationIndex, e -> e.getValue().equals("Location")); contains(annotationIndex, e -> e.getBegin() == 100); contains(annotationIndex, e -> e.getEnd() == 118); contains(annotationIndex, e -> e.getValue().equals("Organisation Ltd")); contains(annotationIndex, e -> e.getBegin() == 12); contains(annotationIndex, e -> e.getEnd() == 18); bcr.close(); }
@Test public void testRelations() throws Exception { BaleenCollectionReader bcr = getCollectionReader( Re3dReader.PARAM_FOLDER, tmpDir.toAbsolutePath().toString(), Re3dReader.PARAM_ENTITIES, true, Re3dReader.PARAM_RELATIONSHIPS, true, Re3dReader.PARAM_RANDOM_DATES, true); assertTrue(bcr.doHasNext()); bcr.getNext(jCas.getCas()); AnnotationIndex<Entity> entityIndex = jCas.getAnnotationIndex(Entity.class); Entity source = Streams.stream(entityIndex).filter(e -> e.getBegin() == 12).findAny().get(); Entity target = Streams.stream(entityIndex).filter(e -> e.getBegin() == 9).findAny().get(); AnnotationIndex<Relation> relationIndex = jCas.getAnnotationIndex(Relation.class); contains(relationIndex, r -> r.getBegin() == 11); contains(relationIndex, r -> r.getEnd() == 12); contains(relationIndex, r -> r.getValue().equals("")); contains(relationIndex, r -> r.getRelationshipType().equals("HasAttrOf")); contains(relationIndex, r -> r.getSource().equals(source)); contains(relationIndex, r -> r.getTarget().equals(target)); bcr.close(); }