// for disjoint spans, just ignore the gap
Span first1 = entityMentions.get(relationInfo.id1).get(0);
Span last1 = entityMentions.get(relationInfo.id1).get(entityMentions.get(relationInfo.id1).size() - 1);
Span span1 = new Span(first1.start, last1.end);
EntityMention entityMention1 = null;
if(spanToEntity.containsKey(span1)) {
// an entity with the same span has already been added to the cas
entityMention1 = spanToEntity.get(span1);
}
else {
// this entity still needs to be addded to the cas
entityMention1 = new EntityMention(jCas, span1.start, span1.end);
entityMention1.setTypeID(Mapper.getEntityTypeId(entityTypes.get(relationInfo.id1)));
entityMention1.setId(identifiedAnnotationId++);
entityMention1.setDiscoveryTechnique(CONST.NE_DISCOVERY_TECH_GOLD_ANNOTATION);
entityMention1.setConfidence(1);
entityMention1.addToIndexes();
spanToEntity.put(span1, entityMention1);
}
// again, rememeber that some entities have disjoint spans
Span first2 = entityMentions.get(relationInfo.id2).get(0);
Span last2 = entityMentions.get(relationInfo.id2).get(entityMentions.get(relationInfo.id2).size() - 1);
Span span2 = new Span(first2.start, last2.end);
EntityMention entityMention2 = null;
if(spanToEntity.containsKey(span2)) {
// an entity with this span already exists in the cas
entityMention2 = spanToEntity.get(span2);
}
else {
// this entity still needs to be added to the cas
entityMention2 = new EntityMention(jCas, span2.start, span2.end);
entityMention2.setTypeID(Mapper.getEntityTypeId(entityTypes.get(relationInfo.id2)));
entityMention2.setId(identifiedAnnotationId++);
entityMention2.setDiscoveryTechnique(CONST.NE_DISCOVERY_TECH_GOLD_ANNOTATION);
entityMention2.setConfidence(1);
entityMention2.addToIndexes();
spanToEntity.put(span2, entityMention2);
}
RelationArgument relationArgument1 = new RelationArgument(jCas);
relationArgument1.setId(relationArgumentId++);