Package org.apache.ctakes.typesystem.type.textsem

Examples of org.apache.ctakes.typesystem.type.textsem.EntityMention


        sentence);

    // Create pairings (this will change depending on the classification direction)
    List<IdentifiedAnnotationPair> pairs = new ArrayList<IdentifiedAnnotationPair>();
    for (int i = 0; i < args.size(); ++i) {
      EntityMention arg1 = args.get(i);
      int jStart = this.classifyBothDirections ? 0 : i + 1;
      for (int j = jStart; j < args.size(); ++j) {
        EntityMention arg2 = args.get(j);
        // skip identical entity mentions and mentions with identical spans
        if (i == j || (arg1.getBegin() == arg2.getBegin() && arg1.getEnd() == arg2.getEnd())) {
          continue;
        }
        pairs.add(new IdentifiedAnnotationPair(arg1, arg2));
      }
    }
View Full Code Here


        // for disjoint spans, just ignore the gap
        Span first = entry.getValue().get(0);
        Span last = entry.getValue().get(entry.getValue().size() - 1);
       
        EntityMention entityMention = new EntityMention(initView, first.start, last.end);
        entityMention.setTypeID(Mapper.getEntityTypeId(entityTypes.get(entry.getKey())));
        entityMention.setId(identifiedAnnotationId++);
        entityMention.setDiscoveryTechnique(CONST.NE_DISCOVERY_TECH_GOLD_ANNOTATION);
        entityMention.setConfidence(1);
       
        entityMention.addToIndexes();
      }
  }
View Full Code Here

        modifier.addToIndexes();
        spanToModifier.put(modifierSpan, modifier);
      }
     
      // create an entity mention object and add it to the cas
      EntityMention entityMention = null;
      if(spanToEntity.containsKey(entityMentionSpan)) {
        // an entity with the same span has already been added to the cas
        entityMention = spanToEntity.get(entityMentionSpan);
      }
      else {
        // this entity needs to be addded to the cas
        entityMention = new EntityMention(jCas, entityMentionSpan.start, entityMentionSpan.end);
        entityMention.setTypeID(entityMentionType);
        entityMention.setId(identifiedAnnotationId++);
        entityMention.setDiscoveryTechnique(CONST.NE_DISCOVERY_TECH_GOLD_ANNOTATION);
        entityMention.setConfidence(1);
        entityMention.addToIndexes();
        spanToEntity.put(entityMentionSpan, entityMention);
      }

      RelationArgument relationArgument1 = new RelationArgument(jCas);
      relationArgument1.setId(relationArgumentId++);
View Full Code Here

      // 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++);
View Full Code Here

      // ignore all entities that cannot be found by ctakes
      if(Mapper.getEntityTypeId(entityTypes.get(entry.getKey())) == CONST.NE_TYPE_ID_UNKNOWN) {
        continue;
      }

      EntityMention entityMention = new EntityMention(jCas, span.start, span.end);
      entityMention.setTypeID(Mapper.getEntityTypeId(entityTypes.get(entry.getKey())));
      entityMention.setId(identifiedAnnotationId++);
      entityMention.setDiscoveryTechnique(CONST.NE_DISCOVERY_TECH_GOLD_ANNOTATION);
      entityMention.setConfidence(1);
      entityMention.addToIndexes();

      spanToEntity.put(span, entityMention);
    }
  }
View Full Code Here

      Map<String, KnowtatorAnnotation> annotationSlots = new HashMap<String, KnowtatorAnnotation>(
          annotation.annotationSlots);
      KnowtatorAnnotation.Span coveringSpan = annotation.getCoveringSpan();

      if ("Anatomical_site".equals(annotation.type)) {
        EntityMention entityMention = new EntityMention(jCas, coveringSpan.begin, coveringSpan.end);
        addEntityMentionFeatures(
            annotation,
            entityMention,
            jCas,
            CONST.NE_TYPE_ID_ANATOMICAL_SITE,
            stringSlots,
            booleanSlots,
            annotationSlots,
            idAnnotationMap,
            delayedFeatures);
        KnowtatorAnnotation bodySide = annotationSlots.remove("body_side");
        if (bodySide != null) {
          delayedFeatures.add(new DelayedFeature<EntityMention>(entityMention, bodySide) {
            @Override
            protected void setValue(TOP valueAnnotation) {
              // TODO: this.annotation.setBodySide(...)
            }
          });
        }
        KnowtatorAnnotation bodyLaterality = annotationSlots.remove("body_laterality");
        if (bodyLaterality != null) {
          delayedFeatures.add(new DelayedFeature<EntityMention>(entityMention, bodyLaterality) {
            @Override
            protected void setValue(TOP valueAnnotation) {
              // TODO: this.annotation.setBodyLaterality(...)
            }
          });
        }

      } else if ("Disease_Disorder".equals(annotation.type)) {
        EntityMention entityMention = new EntityMention(jCas, coveringSpan.begin, coveringSpan.end);
        addEntityMentionFeatures(
            annotation,
            entityMention,
            jCas,
            CONST.NE_TYPE_ID_DISORDER,
            stringSlots,
            booleanSlots,
            annotationSlots,
            idAnnotationMap,
            delayedFeatures);
        KnowtatorAnnotation bodyLocation = annotationSlots.remove("body_location");
        if (bodyLocation != null) {
          delayedFeatures.add(new DelayedFeature<EntityMention>(entityMention, bodyLocation) {
            @Override
            protected void setValue(TOP valueAnnotation) {
              // TODO: this.annotation.setBodyLocation(...)
            }
          });
        }
        KnowtatorAnnotation severity = annotationSlots.remove("severity");
        if (severity != null) {
          delayedFeatures.add(new DelayedFeature<EntityMention>(entityMention, severity) {
            @Override
            protected void setValue(TOP valueAnnotation) {
              // TODO: this.annotation.setSeverity(...)
            }
          });
        }

      } else if ("Medications/Drugs".equals(annotation.type)) {
        EntityMention entityMention = new EntityMention(jCas, coveringSpan.begin, coveringSpan.end);
        addEntityMentionFeatures(
            annotation,
            entityMention,
            jCas,
            CONST.NE_TYPE_ID_DRUG,
            stringSlots,
            booleanSlots,
            annotationSlots,
            idAnnotationMap,
            delayedFeatures);

      } else if ("Phenomena".equals(annotation.type)) {
        EntityMention entityMention = new EntityMention(jCas, coveringSpan.begin, coveringSpan.end);
        addEntityMentionFeatures(
            annotation,
            entityMention,
            jCas,
            CONST.NE_TYPE_ID_UNKNOWN /* TODO: is this the correct type? */,
            stringSlots,
            booleanSlots,
            annotationSlots,
            idAnnotationMap,
            delayedFeatures);

      } else if ("Procedure".equals(annotation.type)) {
        EntityMention entityMention = new EntityMention(jCas, coveringSpan.begin, coveringSpan.end);
        addEntityMentionFeatures(
            annotation,
            entityMention,
            jCas,
            CONST.NE_TYPE_ID_PROCEDURE,
            stringSlots,
            booleanSlots,
            annotationSlots,
            idAnnotationMap,
            delayedFeatures);
        KnowtatorAnnotation bodyLocation = annotationSlots.remove("body_location");
        if (bodyLocation != null) {
          delayedFeatures.add(new DelayedFeature<EntityMention>(entityMention, bodyLocation) {
            @Override
            protected void setValue(TOP valueAnnotation) {
              // TODO: this.annotation.setBodyLocation(...)
            }
          });
        }
        KnowtatorAnnotation historyOf = annotationSlots.remove("historyOf_CU");
        if (historyOf != null) {
          delayedFeatures.add(new DelayedFeature<EntityMention>(entityMention, historyOf) {
            @Override
            protected void setValue(TOP valueAnnotation) {
              // TODO: this.annotation.setHistoryOf(...)
            }
          });
        }

      } else if ("Sign_symptom".equals(annotation.type)) {
        EntityMention entityMention = new EntityMention(jCas, coveringSpan.begin, coveringSpan.end);
        addEntityMentionFeatures(
            annotation,
            entityMention,
            jCas,
            CONST.NE_TYPE_ID_FINDING,
View Full Code Here

            IdentifiedAnnotation neAnnot;
            if (neType.intValue() == CONST.NE_TYPE_ID_DRUG) {
              neAnnot = new MedicationEventMention(jcas)
            } else {
              neAnnot = new EntityMention(jcas)
           
            }

            neAnnot.setTypeID(neType.intValue());
            neAnnot.setBegin(neBegin);
View Full Code Here

      IdentifiedAnnotation neAnnot;
      if (tid == CONST.NE_TYPE_ID_DRUG || tid == CONST.NE_TYPE_ID_UNKNOWN) {
        neAnnot = new MedicationEventMention(jcas)
      } else {
        neAnnot = new EntityMention(jcas)
     
      }
     
      neAnnot.setBegin(neBegin);
      neAnnot.setEnd(neEnd);
View Full Code Here

    tokenBuilder.buildTokens(
        jCas,
        "He had a slight fracture in the proximal right fibula.",
        "He had a slight fracture in the proximal right fibula .",
        "PRP VBD DT JJ NN IN DT JJ JJ NN .");
    EntityMention fracture = new EntityMention(jCas, 16, 24);
    fracture.setTypeID(CONST.NE_TYPE_ID_DISORDER);
    fracture.addToIndexes();
    assertEquals("fracture", fracture.getCoveredText());
    EntityMention fibula = new EntityMention(jCas, 32, 53);
    fibula.setTypeID(CONST.NE_TYPE_ID_ANATOMICAL_SITE);
    fibula.addToIndexes();
    assertEquals("proximal right fibula", fibula.getCoveredText());

    // run the analysis engine
    engine.process(jCas);

    // test the modifier annotator
View Full Code Here

  public static ArrayList<Annotation> selectNE (JCas jcas) {
    ArrayList<Annotation> ret = new ArrayList<Annotation>();
    FSIterator iter = jcas.getJFSIndexRepository().getAnnotationIndex(EntityMention.type).iterator();
    while (iter.hasNext()) {
      EntityMention a = (EntityMention) iter.next();
      if(a.getOntologyConceptArr() != null)
//      int tid = a.getTypeID();
//      if (tid == TypeSystemConst.NE_TYPE_ID_ANATOMICAL_SITE ||
//        tid == TypeSystemConst.NE_TYPE_ID_DISORDER ||
//        tid == TypeSystemConst.NE_TYPE_ID_PROCEDURE ||
//        tid == TypeSystemConst.NE_TYPE_ID_FINDING)
View Full Code Here

TOP

Related Classes of org.apache.ctakes.typesystem.type.textsem.EntityMention

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.