Examples of RelationArgument


Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

    for(Element linkEl : dataElem.getChild("TAGS").getChildren("TLINK")){
      Annotation fromEnt = id2entity.get(linkEl.getAttributeValue("fromID"));
      Annotation toEnt = id2entity.get(linkEl.getAttributeValue("toID"));
      String cat = linkEl.getAttributeValue("type");
      TemporalTextRelation link = new TemporalTextRelation(jcas);
      RelationArgument arg1 = new RelationArgument(jcas);
      arg1.setArgument(fromEnt);
      link.setArg1(arg1);
      RelationArgument arg2 = new RelationArgument(jcas);
      arg2.setArgument(toEnt);
      link.setArg2(arg2);
      if(mapThyme){
        throw new UnsupportedOperationException("Mapping to THYME relations is not implemented yet!");
      }else{
        if(beforeSet.contains(cat)){
          link.setCategory("BEFORE");
        }else if(afterSet.contains(cat)){
          link.setCategory("AFTER");
        }else{
          link.setCategory("OVERLAP");
        }
//        link.setCategory(cat);
      }
      link.addToIndexes();
      arg1.addToIndexes();
      arg2.addToIndexes();
    }
  }
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

      String causeID) {
    if (sourceID != null && targetID != null) {
      Annotation source = getArgument(sourceID, idToAnnotation, causeID);
      Annotation target = getArgument(targetID, idToAnnotation, causeID);
      if (source != null && target != null) {
        RelationArgument sourceArg = new RelationArgument(jCas);
        sourceArg.setArgument(source);
        sourceArg.addToIndexes();
        RelationArgument targetArg = new RelationArgument(jCas);
        targetArg.setArgument(target);
        targetArg.addToIndexes();
        relation.setCategory(category);
        relation.setArg1(sourceArg);
        relation.setArg2(targetArg);
        relation.addToIndexes();
      }
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

        LocationOfTextRelation locationOfTextRelation = null;
        if (binaryTextRelation instanceof LocationOfTextRelation) {
          locationOfTextRelation = (LocationOfTextRelation) binaryTextRelationFS;
        }
       
        RelationArgument arg1 = binaryTextRelation.getArg1(); // an EntityMention  OR  location
        RelationArgument arg2 = binaryTextRelation.getArg2(); // a Modifier  OR   what is located at location
        String relation = binaryTextRelation.getCategory(); // "degree_of", "location_of"

        if (relation.equals("degree_of")) {
         
          // do nothing here, this loop is for dealing with location_of
          // degree_of has its own loop.
         
        } else if (relation.equals("location_of")) {

          IdentifiedAnnotation arg1Arg = (IdentifiedAnnotation) arg1.getArgument();
          IdentifiedAnnotation ia = mapToMentions.get(arg1Arg);

          if (ia instanceof EntityMention) {
           
            // Note you apparently can have an AnatomicalSiteMention be the location_of an AnatomicalSiteMention
            // from running rec041, end up with things like "Left lower extremity"  location_of "common femoral vein"
            // and "left renal vein" in relation location_of to anatomical site mention "renal vein"
            // and "vein" in relation location_of to anatomical site mention "renal vein"
            EntityMention entityMention = (EntityMention) ia;
            IdentifiedAnnotation location = (IdentifiedAnnotation) arg2.getArgument();
            IdentifiedAnnotation loc = (IdentifiedAnnotation)mapToMentions.get(location);
            if (loc instanceof AnatomicalSiteMention) {
              AnatomicalSiteMention asm = (AnatomicalSiteMention) loc;
              //asm.setBodyLocation(binaryTextRelation); // uncomment iff AnatomicalSiteMention ends up with a bodyLocation attribute
            } else {
              logger.error("Need to implement cases for handling EntityMention " + entityMention + " within relation: " + relation);
              logger.error("   loc " + loc + " in relation " + relation + " with/to " + entityMention);
              logger.error("   Using covered text: loc " + loc.getCoveredText() + " in relation " + relation + " with/to " + entityMention.getCoveredText());
            }

          } else {
           
            EventMention eventMention = (EventMention) ia;

            if (eventMention instanceof DiseaseDisorderMention) { //(eventMention.getTypeID()==CONST.NE_TYPE_ID_DISORDER) {
              DiseaseDisorderMention ddm = (DiseaseDisorderMention) eventMention;
              ddm.setBodyLocation(locationOfTextRelation);
            } else if (eventMention instanceof ProcedureMention) { //(eventMention.getTypeID()==CONST.NE_TYPE_ID_PROCEDURE) {
              ProcedureMention pm = (ProcedureMention) eventMention;
              pm.setBodyLocation(locationOfTextRelation);
            } else if (eventMention instanceof SignSymptomMention) { //(eventMention.getTypeID()==CONST.NE_TYPE_ID_FINDING) {
              SignSymptomMention ssm = (SignSymptomMention) eventMention;
              ssm.setBodyLocation(locationOfTextRelation);
            } else {
              logger.error("Need to implement more cases for handling EventMention " + eventMention + " within relation: " + relation);
            }
           
          }
        } else {
          logger.error("Need to implement more cases for relation: " + relation);
        }
      }
  }
 
  if (degreeOfTextRelations != null) {
   
      for (FeatureStructure binaryTextRelationFS: degreeOfTextRelations) {
       
        i++;
        //logger.info("binaryTextRelationFS = " + binaryTextRelationFS);
        BinaryTextRelation binaryTextRelation = (BinaryTextRelation) binaryTextRelationFS;
        DegreeOfTextRelation degreeOfTextRelation = null;
        if (binaryTextRelation instanceof DegreeOfTextRelation) {
          degreeOfTextRelation = (DegreeOfTextRelation) binaryTextRelationFS;
        }
       
        RelationArgument arg1 = binaryTextRelation.getArg1(); // an EntityMention  OR  location
        RelationArgument arg2 = binaryTextRelation.getArg2(); // a Modifier  OR   what is located at location
        String relation = binaryTextRelation.getCategory(); // "degree_of", "location_of"

        if (relation.equals("degree_of")) {
         
          Modifier severity = (Modifier) arg2.getArgument();
          // degree_of is aka severity, which applies to SignSymptomMention/SignSymptom and DiseaseDisorder
          // find Mention associated with arg1
          IdentifiedAnnotation arg1Arg = (IdentifiedAnnotation) arg1.getArgument();
          // set severity within the Mention to be arg2 (the Modifier)
          // Note at this point mapToMentions.get(entityMention) might be an entityMention instead of an EventMention
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

      if (relation.getCategory() == null) {
        relation.setCategory(this.annotation.type);
      }
     
      // link the relation to its arguments and add it to the CAS
      RelationArgument sourceRA = new RelationArgument(jCas);
      sourceRA.setArgument(sourceMention);
      sourceRA.addToIndexes();
      RelationArgument targetRA = new RelationArgument(jCas);
      targetRA.setArgument(targetMention);
      targetRA.addToIndexes();
      relation.setArg1(sourceRA);
      relation.setArg2(targetRA);
      relation.addToIndexes();
   
      // add the relation to the map so it can be used in features of other annotations
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

      if(bestAnte.prob > CorefConsts.COREF_THRESHOLD){
        // create the coref relation type
        CoreferenceRelation cr = new CoreferenceRelation(jcas);
        cr.setCategory("Coreference");
        RelationArgument ra1 = new RelationArgument(jcas);
        ra1.setId(bestAnte.m.getId());
        ra1.setArgument(bestAnte.m.getContent());
        ra1.setRole("antecedent");
        RelationArgument ra2 = new RelationArgument(jcas);
        ra2.setId(anaphor.getId());
        ra2.setArgument(anaphor.getContent());
        ra2.setRole("anaphor");
        cr.setArg1(ra1);
        cr.setArg2(ra2);
        cr.setConfidence(bestAnte.prob);
        ra1.addToIndexes();
        ra2.addToIndexes();
        cr.addToIndexes();
       
        // propagate the collection relation type
        RelationArgument anaRa = new RelationArgument(jcas);
        anaRa.setId(anaphor.getId());
        anaRa.setArgument(anaphor.getContent());
        anaRa.setRole("mention");
        NonEmptyFSList node = new NonEmptyFSList(jcas);
        node.setHead(anaRa);
        node.setTail(emptyList);
        collectionRas.put(anaphor, node);
        NonEmptyFSList anteNode = null;
        if(collectionRas.containsKey(bestAnte.m)){
          anteNode = collectionRas.get(bestAnte.m);
          // find the end of the chain of this node
          while(anteNode.getTail() instanceof NonEmptyFSList){
            anteNode = (NonEmptyFSList) anteNode.getTail();
          }
        }else{
          RelationArgument anteRa = new RelationArgument(jcas);
          anteRa.setId(bestAnte.m.getId());
          anteRa.setArgument(bestAnte.m.getContent());
          anteRa.setRole("mention");
         
          anteNode = new NonEmptyFSList(jcas);
          anteNode.setHead(anteRa);
          collectionRas.put(bestAnte.m, anteNode);
          CollectionTextRelation chain = new CollectionTextRelation(jcas);
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

  protected void createRelation(
      JCas jCas,
      IdentifiedAnnotation arg1,
      IdentifiedAnnotation arg2,
      String predictedCategory) {
    RelationArgument relArg1 = new RelationArgument(jCas);
    relArg1.setArgument(arg1);
    relArg1.setRole("Argument");
    relArg1.addToIndexes();
    RelationArgument relArg2 = new RelationArgument(jCas);
    relArg2.setArgument(arg2);
    relArg2.setRole("Related_to");
    relArg2.addToIndexes();
    LocationOfTextRelation relation = new LocationOfTextRelation(jCas);
    relation.setArg1(relArg1);
    relation.setArg2(relArg2);
    relation.setCategory(predictedCategory);
    relation.addToIndexes();
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

  protected void createRelation(
      JCas jCas,
      IdentifiedAnnotation arg1,
      IdentifiedAnnotation arg2,
      String predictedCategory) {
    RelationArgument relArg1 = new RelationArgument(jCas);
    relArg1.setArgument(arg1);
    relArg1.setRole("Argument");
    relArg1.addToIndexes();
    RelationArgument relArg2 = new RelationArgument(jCas);
    relArg2.setArgument(arg2);
    relArg2.setRole("Related_to");
    relArg2.addToIndexes();
    DegreeOfTextRelation relation = new DegreeOfTextRelation(jCas);
    relation.setArg1(relArg1);
    relation.setArg2(relArg2);
    relation.setCategory(predictedCategory);
    relation.addToIndexes();
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

      JCas jCas,
      IdentifiedAnnotation arg1,
      IdentifiedAnnotation arg2,
      String predictedCategory) {
    // add the relation to the CAS
    RelationArgument relArg1 = new RelationArgument(jCas);
    relArg1.setArgument(arg1);
    relArg1.setRole("Argument");
    relArg1.addToIndexes();
    RelationArgument relArg2 = new RelationArgument(jCas);
    relArg2.setArgument(arg2);
    relArg2.setRole("Related_to");
    relArg2.addToIndexes();
    BinaryTextRelation relation = new BinaryTextRelation(jCas);
    relation.setArg1(relArg1);
    relation.setArg2(relArg2);
    relation.setCategory(predictedCategory);
    relation.addToIndexes();
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

      if (relation.getCategory() == null) {
        relation.setCategory(this.annotation.type);
      }
     
      // link the relation to its arguments and add it to the CAS
      RelationArgument sourceRA = new RelationArgument(jCas);
      sourceRA.setArgument(sourceMention);
      sourceRA.addToIndexes();
      RelationArgument targetRA = new RelationArgument(jCas);
      targetRA.setArgument(targetMention);
      targetRA.addToIndexes();
      relation.setArg1(sourceRA);
      relation.setArg2(targetRA);
      relation.addToIndexes();
   
      // add the relation to the map so it can be used in features of other annotations
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

          locationOfTextRelation = (LocationOfTextRelation) binaryTextRelationFS;
        } else if (binaryTextRelation instanceof DegreeOfTextRelation) {
          degreeOfTextRelation = (DegreeOfTextRelation) binaryTextRelationFS;
        }
       
        RelationArgument arg1 = binaryTextRelation.getArg1(); // an EntityMention  OR  location
        RelationArgument arg2 = binaryTextRelation.getArg2(); // a Modifier  OR   what is located at location
        String relation = binaryTextRelation.getCategory(); // "degree_of", "location_of"

        if (relation.equals("degree_of")) {
         
          Modifier severity = (Modifier) arg2.getArgument();
          // degree_of is aka severity, which applies to SignSymptomMention/SignSymptom and DiseaseDisorder
          // find Mention associated with arg1
          IdentifiedAnnotation arg1Arg = (IdentifiedAnnotation) arg1.getArgument();
          // set severity within the Mention to be arg2 (the Modifier)
          // Note at this point mapToMentions.get(entityMention) might be an entityMention instead of an EventMention
          // for example rec041 in the seed set resulted in
          //  ClassCastException: org.apache.ctakes.typesystem.type.textsem.AnatomicalSiteMention
          //  cannot be cast to org.apache.ctakes.typesystem.type.textsem.EventMention
          IdentifiedAnnotation ia = mapToMentions.get(arg1Arg);
          if (ia instanceof EntityMention) {
            EntityMention entityMention = (EntityMention) ia;
            logger.error("Need to implement cases for handling EntityMention " + entityMention + " within relation: " + relation);
            logger.error("   severity " + severity + " in relation " + relation + " with/to " + entityMention);
            logger.error("   Using covered text: severity " + severity.getCoveredText() + " in relation " + relation + " with/to " + entityMention.getCoveredText());
          } else {
            EventMention eventMention = (EventMention) ia;
            if (eventMention instanceof DiseaseDisorderMention) {
              DiseaseDisorderMention ddm = (DiseaseDisorderMention) eventMention;
              logger.error("Need to implement attr for " + relation + " for DiseaseDisorderMention");
            } else if (eventMention instanceof SignSymptomMention) {
              SignSymptomMention ssm = (SignSymptomMention) eventMention;
              ssm.setSeverity(degreeOfTextRelation);
            } else {
              logger.error("Need to implement more cases for handling EventMention " + eventMention + " within relation: " + relation);
            }
          }
         
        } else if (relation.equals("location_of")) {

          EntityMention arg2Arg = (EntityMention) arg2.getArgument(); // wrongly created as EntityMention prior to 3.0
          IdentifiedAnnotation ia = mapToMentions.get(arg2Arg);

          if (ia instanceof EntityMention) {
           
            // Note you apparently can have an AnatomicalSiteMention be the location_of an AnatomicalSiteMention
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.