private void addEntity(JCas jcas, int entityPosStart, int entityPosEnd, String entityId) { EntityMention entityAnno = new EntityMention(jcas, entityPosStart, entityPosEnd); entityAnno.setSpecificType(entityId); entityAnno.addToIndexes(); // EntityMention e = entityAnno; // String s = jcas.getDocumentText(); // System.out.println(s.substring(0,e.getBegin())+"#" + // e.getCoveredText() + "#" +s.substring(e.getEnd(),s.length())); }
/** @generated * @param jcas JCas to which this Feature Structure belongs * @param begin offset to the begin spot in the SofA * @param end offset to the end spot in the SofA */ public EntityMention(JCas jcas, int begin, int end) { super(jcas); setBegin(begin); setEnd(end); readObject(); }
public void writeEntity(EntityMention entity) throws IOException { String id = entity.getId(); writtenIds.add(id); String line = entity.getId() + "\t" + "Entity" + " " + entity.getBegin() + " " + entity.getEnd() + "\t" + documentText.substring(entity.getBegin(), entity.getEnd()) + "\n"; writer.write(line); }
for (Iterator<Annotation> it = aJCas.getAnnotationIndex(t).iterator(); it.hasNext();) { EntityMention em = (EntityMention) it.next(); String specificType = em.getSpecificType(); JCoReSetAnnotationIndex<EntityMention> specificIndex = indexMap.get(specificType); if (null == specificIndex) { JCoReSetAnnotationIndex<EntityMention> specificIndex = indexMap.get(specificType); new ArrayList<>(specificIndex.getIndex()).stream().forEach(entity -> { String entityName = entity.getCoveredText(); if (!processedEntityNames.add(entityName)) return; if (end >= 0 && aJCas.getDocumentText().substring(begin, end).equals(entityName)) { refEntity = (EntityMention) aJCas.getCas().createAnnotation(t, begin, end); refEntity.setBegin(begin); refEntity.setEnd(end); refEntity.setSpecificType(entity.getSpecificType()); refEntity.setResourceEntryList(entity.getResourceEntryList()); refEntity.setConfidence(entity.getConfidence()); refEntity.setTextualRepresentation(entity.getTextualRepresentation()); refEntity.setComponentId(COMPONENT_ID + " String (" + entity.getCoveredText() + ", " + begin + "-" + end + ")"); return refEntity; return e; }).collect(Collectors.toList()).stream().forEach(e -> { e.addToIndexes(); }); });
final EntityMention newEntityMention = (EntityMention) JCoReAnnotationTools .getAnnotationByClassName(aJCas, refEntityMention.getClass().getName()); newEntityMention.setBegin(abbreviation.getBegin()); newEntityMention.setEnd(abbreviation.getEnd()); newEntityMention.setSpecificType(refEntityMention.getSpecificType()); newEntityMention.setResourceEntryList(refEntityMention.getResourceEntryList()); newEntityMention.setConfidence(refEntityMention.getConfidence()); newEntityMention.setComponentId(COMPONENT_ID + " Abbrev"); newEntityMention.addToIndexes(); } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalArgumentException | InstantiationException | IllegalAccessException final EntityMention newEntityMention = (EntityMention) JCoReAnnotationTools .getAnnotationByClassName(aJCas, refEntityMention.getClass().getName()); newEntityMention.setBegin(fullform.getBegin()); newEntityMention.setEnd(fullform.getEnd()); newEntityMention.setSpecificType(refEntityMention.getSpecificType()); newEntityMention.setResourceEntryList(refEntityMention.getResourceEntryList()); newEntityMention.setConfidence(refEntityMention.getConfidence()); newEntityMention.setComponentId(COMPONENT_ID + " Abbrev"); newEntityMention.addToIndexes(); } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalArgumentException | InstantiationException | IllegalAccessException
entity = (EntityMention) JCoReAnnotationTools.getAnnotationByClassName(aJCas, entityType); entity.setBegin(start); entity.setEnd(end); entity.setTextualRepresentation(aJCas.getDocumentText().substring(start, end)); entity.setSpecificType(label); entity.setComponentId(COMPONENT_ID); if (showSegmentConf) entity.setConfidence(confidence + ""); entity.addToIndexes(); } catch (Exception e) { LOGGER.error("addAnnotation() - could not generate new EntityMention", e);
public boolean isWritten(EntityMention entity) { return writtenIds.contains(entity.getId()); } }
while (entityIter.hasNext()) { final EntityMention entity = (EntityMention) entityIter.next(); entityMap.put(entity.getCoveredText(), entity); if (!StringUtils.isBlank(entity.getSpecificType())) specificType = entity.getSpecificType(); JCoReSetAnnotationIndex<EntityMention> set = overlapIndex.get(specificType); if (null == set) { final EntityMention entity = entityMap.get(entityString).iterator().next(); String specificType = "<null>"; if (!StringUtils.isBlank(entity.getSpecificType())) specificType = entity.getSpecificType(); JCoReSetAnnotationIndex<EntityMention> overlapSet = overlapIndex.get(specificType); mentionForOffsetComparison.setBegin(pos); mentionForOffsetComparison.setEnd(pos + length); boolean overlappingExists = overlapSet.contains(mentionForOffsetComparison); refEntity.setBegin(begin); refEntity.setEnd(end); refEntity.setSpecificType(entity.getSpecificType()); refEntity.setResourceEntryList(entity.getResourceEntryList()); refEntity.setConfidence(entity.getConfidence()); refEntity.setTextualRepresentation(entity.getTextualRepresentation()); refEntity.setComponentId(COMPONENT_ID + " String (" + entity.getCoveredText() + ", " + begin + "-" + end + ")"); stringMatchedEntities.add(refEntity);