protected CorefMention corefMention(Entity entity, int chainId) { int headIndex = 0; for (int i = 0; i < entities.size(); i++) { Optional<Entity> optional = entities.get(i); if (optional.isPresent() && entity.equals(optional.get())) { headIndex = i; break; } } return new CorefMention( sentenceIndex, headIndex, entity.getBegin() - getBegin(), entity.getEnd() - getBegin(), chainId); }
protected CorefMention corefMention(Entity entity, int chainId) { int headIndex = 0; for (int i = 0; i < entities.size(); i++) { Optional<Entity> optional = entities.get(i); if (optional.isPresent() && entity.equals(optional.get())) { headIndex = i; break; } } return new CorefMention( sentenceIndex, headIndex, entity.getBegin() - getBegin(), entity.getEnd() - getBegin(), chainId); }
@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(); }