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

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


    }
    Set<HashableAnnotation> all = Sets.union(goldMap.keySet(), systemMap.keySet());
    List<HashableAnnotation> sorted = Lists.newArrayList(all);
    Collections.sort(sorted);
    for (HashableAnnotation key : sorted) {
      IdentifiedAnnotation goldAnnotation = goldMap.get(key);
      IdentifiedAnnotation systemAnnotation = systemMap.get(key);
      Object goldLabel=null;
      Object systemLabel=null;
      if (goldAnnotation == null) {
        logger.debug(key + " not found in gold annotations ");
      } else {
        Feature feature = goldAnnotation.getType().getFeatureByBaseName(classifierType);
        goldLabel = getFeatureValue(feature, categoryClass, goldAnnotation);
        //  Integer goldLabel = goldAnnotation.getIntValue(feature);
      }
     
      if (systemAnnotation == null) {
        logger.info(key + " not found in system annotations ");
      } else {
        Feature feature = systemAnnotation.getType().getFeatureByBaseName(classifierType);
        systemLabel = getFeatureValue(feature, categoryClass, systemAnnotation);
        //  Integer systemLabel = systemAnnotation.getIntValue(feature);
      }
     
      String typeId;
      if (systemAnnotation!=null) {
        typeId = systemAnnotation.getTypeID()+"";
      } else  {
        typeId = "X";
      }
     
      if (goldLabel==null) {
View Full Code Here


//    assertEquals(-1, ne1.getPolarity());

  }

  private IdentifiedAnnotation addNE(JCas jCas, int neBegin, int neEnd, String neText) throws ResourceInitializationException, AnalysisEngineProcessException {
    IdentifiedAnnotation namedEntity = new IdentifiedAnnotation(jCas, neBegin, neEnd);
    namedEntity.addToIndexes();
    assertEquals(neText, namedEntity.getCoveredText());
    return namedEntity;
  }
View Full Code Here

//    assertEquals(2, ne3.getUncertainty());

  }

  private IdentifiedAnnotation addNE(JCas jCas, int neBegin, int neEnd, String neText) throws ResourceInitializationException, AnalysisEngineProcessException {
    IdentifiedAnnotation IdentifiedAnnotation = new IdentifiedAnnotation(jCas, neBegin, neEnd);
    IdentifiedAnnotation.addToIndexes();
    assertEquals(neText, IdentifiedAnnotation.getCoveredText());
    return IdentifiedAnnotation;
  }
View Full Code Here

        first = mention.getValue().get(0);
        last = mention.getValue().get(mention.getValue().size() - 1);

        // put entity and attributes into the CAS
        // choose either entity or event
        IdentifiedAnnotation eMention;
        int type = Mapper.getEntityTypeId(entityTypes.get(mentionId));
        if (type==CONST.NE_TYPE_ID_ANATOMICAL_SITE) {
          eMention = new EntityMention(initView, first.start, last.end)
        } else if (type==CONST.NE_TYPE_ID_DISORDER
            || type==CONST.NE_TYPE_ID_DRUG
            || type==CONST.NE_TYPE_ID_FINDING
            || type==CONST.NE_TYPE_ID_PROCEDURE
            || type==CONST.NE_TYPE_ID_ANATOMICAL_SITE
            ) {
          eMention = new EventMention(initView, first.start, last.end);
        } else {
          eMention = new IdentifiedAnnotation(initView, first.start, last.end);
        }
       
        // set easy attributes
        eMention.setTypeID(Mapper.getEntityTypeId(entityTypes.get(mentionId)));
        eMention.setId(identifiedAnnotationId++);
        eMention.setDiscoveryTechnique(CONST.NE_DISCOVERY_TECH_GOLD_ANNOTATION);
        eMention.setConfidence(1);

        if (mentionId.endsWith("4351")) {
          System.out.println();
        }
       
          List<ArgumentInfo> assocAttributes = getLeafAttributes(mentionId,
              mentionAttr,attrPtr,attrs,new ArrayList<ArgumentInfo>());
         
          for (ArgumentInfo a : assocAttributes) {

//        // set harder attributes from cas -- look through all attribute ids attached to this mentionId
//        for (String attrId : mentionAttr.get(mentionId) ) {
//          // make sure this attribute was actually somewhere in the knowtator file
//          if (!attrs.containsKey(attrId)) {
//            if (VERBOSE) { System.err.println("WARNING: attribute not found: "+attrId); }
//            continue;
//          }
         
          // look up the attribute id and set values accordingly
          checkForAttrValue(eMention, a.role, a.value);
        }
       
        // add to CAS
        eMention.addToIndexes();
      }
  }
View Full Code Here

  private void generateUidValues(JCas jcas) {
    int uid = 0;
    Iterator itr = jcas.getJFSIndexRepository().getAnnotationIndex(
        IdentifiedAnnotation.type).iterator();
    while (itr.hasNext()) {
      IdentifiedAnnotation idAnnot = (IdentifiedAnnotation) itr.next();
      idAnnot.setId(uid);
      uid++;
    }
  }
View Full Code Here

    // For each NE, assign segment ID and assign ontology concept OIDs if applicable
    Iterator neItr = indexes.getAnnotationIndex(IdentifiedAnnotation.type).iterator();
    while (neItr.hasNext()) {
     
      IdentifiedAnnotation neAnnot = (IdentifiedAnnotation) neItr.next();

      // assign segment ID
      Iterator segItr = segmentSet.iterator();
      while (segItr.hasNext()) {
        Segment seg = (Segment) segItr.next();
        // see if NE is inside this segment
        if ((neAnnot.getBegin() >= seg.getBegin())
            && (neAnnot.getEnd() <= seg.getEnd())) {
          // found segment for this NE
          neAnnot.setSegmentID(seg.getId());
          break;
        }
      }

      // assign ontology concept OID values
      FSArray ocArr = neAnnot.getOntologyConceptArr();
      if (ocArr != null) {
        for (int i = 0; i < ocArr.size(); i++) {
          OntologyConcept oc = (OntologyConcept) ocArr.get(i);
          String code = oc.getCode();
          String scheme = oc.getCodingScheme();
View Full Code Here

   */
  private static void copyAnnotation(Annotation goldAnnotation, JCas jcas) {
   
    Annotation newAnno;
    if (goldAnnotation instanceof IdentifiedAnnotation) {
      IdentifiedAnnotation ia = new IdentifiedAnnotation(jcas);
      ia.setConditional(((IdentifiedAnnotation) goldAnnotation).getConditional());
      ia.setConfidence(((IdentifiedAnnotation) goldAnnotation).getConfidence());
          ia.setDiscoveryTechnique(((IdentifiedAnnotation)goldAnnotation).getDiscoveryTechnique());
      ia.setGeneric(((IdentifiedAnnotation) goldAnnotation).getGeneric());
      ia.setHistoryOf(((IdentifiedAnnotation) goldAnnotation).getHistoryOf());
      ia.setPolarity(((IdentifiedAnnotation) goldAnnotation).getPolarity());
      ia.setSegmentID(((IdentifiedAnnotation) goldAnnotation).getSegmentID());
      ia.setSentenceID(((IdentifiedAnnotation) goldAnnotation).getSentenceID());
      ia.setSubject(((IdentifiedAnnotation) goldAnnotation).getSubject());
      ia.setTypeID(((IdentifiedAnnotation) goldAnnotation).getTypeID());
      ia.setUncertainty(((IdentifiedAnnotation) goldAnnotation).getUncertainty());
      newAnno = ia;
    } else {
      throw new RuntimeException("Unexpected class of object " + goldAnnotation.getClass());
    }

View Full Code Here

    }
    Set<HashableAnnotation> all = Sets.union(goldMap.keySet(), systemMap.keySet());
    List<HashableAnnotation> sorted = Lists.newArrayList(all);
    Collections.sort(sorted);
    for (HashableAnnotation key : sorted) {
      IdentifiedAnnotation goldAnnotation = goldMap.get(key);
      IdentifiedAnnotation systemAnnotation = systemMap.get(key);
      Object goldLabel=null;
      Object systemLabel=null;
      if (goldAnnotation == null) {
        logger.debug(key + " not found in gold annotations ");
      } else {
        Feature feature = goldAnnotation.getType().getFeatureByBaseName(classifierType);
        goldLabel = getFeatureValue(feature, categoryClass, goldAnnotation);
        //  Integer goldLabel = goldAnnotation.getIntValue(feature);
      }
     
      if (systemAnnotation == null) {
        logger.info(key + " not found in system annotations ");
      } else {
        Feature feature = systemAnnotation.getType().getFeatureByBaseName(classifierType);
        systemLabel = getFeatureValue(feature, categoryClass, systemAnnotation);
        //  Integer systemLabel = systemAnnotation.getIntValue(feature);
      }
     
      String typeId;
      if (systemAnnotation!=null) {
        typeId = systemAnnotation.getTypeID()+"";
      } else  {
        typeId = "X";
      }
     
      if (goldLabel==null) {
View Full Code Here

  public void consumeHit(JCas jcas, Annotation focusAnnot, int scope,
      ContextHit ctxHit) {
    Integer status = (Integer) ctxHit
        .getMetaData(DxContextAnalyzerImpl.CTX_HIT_KEY_ILLNESS_TYPE);
    if (focusAnnot instanceof IdentifiedAnnotation) {
      IdentifiedAnnotation neAnnot = (IdentifiedAnnotation) focusAnnot;
      if (neAnnot.getTypeID() == 6 || neAnnot.getTypeID() == 7
          || neAnnot.getTypeID() == 0)
        // TODO: Status Family History, History Of, etc. are constant
        // strings?
        neAnnot.setUncertainty(status);
    }

    createContextAnnot(jcas, focusAnnot, scope, ctxHit).addToIndexes();
  }
View Full Code Here

  public void consumeHit(JCas jcas, Annotation focusAnnot, int scope,
      ContextHit ctxHit)
  {
    if (focusAnnot instanceof IdentifiedAnnotation)
    {
      IdentifiedAnnotation neAnnot = (IdentifiedAnnotation) focusAnnot;
      if (neAnnot.getTypeID() != 7 /*&& neAnnot.getTypeID() != 2*/ )
        neAnnot.setPolarity(-1);
    }

    createContextAnnot(jcas, focusAnnot, scope, ctxHit).addToIndexes();
  }
View Full Code Here

TOP

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

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.