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

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


    {
      if (!(identifiedAnnotation instanceof EntityMention || identifiedAnnotation instanceof EventMention))
      {
        continue;
      }
      IdentifiedAnnotation entityOrEventMention = identifiedAnnotation;
      if (entityOrEventMention.getPolarity() == -1)
      {
        logger.debug(String.format(" - identified annotation: [%d-%d] polarity %d (%s)",
            entityOrEventMention.getBegin(),
            entityOrEventMention.getEnd(),
            entityOrEventMention.getPolarity(),
            entityOrEventMention.getClass().getName()));
      }
      Instance<String> instance = new Instance<String>();
     
//      // extract all features that require only the entity mention annotation
//      instance.addAll(tokenFeatureExtractor.extract(jCas, entityMention));

      // extract all features that require the token and sentence annotations

      //Sentence sentence = sentenceList.iterator().next();
     
      /*
      if (sentence != null)
      {
        for (ContextExtractor<IdentifiedAnnotation> extractor : this.contextFeatureExtractors) {
          instance.addAll(extractor.extractWithin(identifiedAnnotationView, entityMention, sentence));
        }
      } else
      {
        // TODO extract context features for annotations that don't fall within a sentence
        logger.log(Level.WARN, "FIXME/TODO: generate context features for entities that don't fall within a sentence");
      }
      */
     
      /*
      for (ContextExtractor<BaseToken> extractor : this.tokenContextFeatureExtractors) {
          instance.addAll(extractor.extract(identifiedAnnotationView, entityMention));
        }
        */
      for (CleartkExtractor extractor : this.tokenCleartkExtractors) {
          //instance.addAll(extractor.extractWithin(identifiedAnnotationView, entityMention, sentence));
        instance.addAll(extractor.extract(identifiedAnnotationView, entityOrEventMention));
        }
     
//      List<Feature> cuePhraseFeatures = null;
//          cuePhraseInWindowExtractor.extract(jCas, entityOrEventMention);
          //cuePhraseInWindowExtractor.extractWithin(jCas, entityMention, firstCoveringSentence);
//      List<Sentence> sents = new ArrayList<Sentence>(coveringSents.get(entityOrEventMention));
      List<Sentence> sents = new ArrayList<Sentence>(JCasUtil.selectCovering(jCas, Sentence.class, entityOrEventMention.getBegin(), entityOrEventMention.getEnd()));
      if(sents.size() > 0){
        Sentence sentence = sents.get(0);
        List<AssertionCuePhraseAnnotation> cues = JCasUtil.selectCovered(AssertionCuePhraseAnnotation.class, sentence);
        int closest = Integer.MAX_VALUE;
        AssertionCuePhraseAnnotation closestCue = null;
        for(AssertionCuePhraseAnnotation cue : cues){
          List<BaseToken> tokens = JCasUtil.selectBetween(BaseToken.class, cue, entityOrEventMention);
          if(tokens.size() < closest){
            closestCue = cue;
            closest = tokens.size();
          }
//          instance.addAll(cuePhraseInWindowExtractor.extractBetween(jCas, cue, entityOrEventMention));
        }
        if(closestCue != null && closest < 21){
          instance.add(new Feature("ClosestCue_Word", closestCue.getCoveredText()));
//          instance.add(new Feature("ClosestCue_Phrase", closestCue.getCuePhrase()));
          instance.add(new Feature("ClosestCue_PhraseFamily", closestCue.getCuePhraseAssertionFamily()));
          instance.add(new Feature("ClosestCue_PhraseCategory", closestCue.getCuePhraseCategory()));
        }
      }
//      if (cuePhraseFeatures != null && !cuePhraseFeatures.isEmpty())
//      {
//        instance.addAll(cuePhraseFeatures);
//      }


      // 7/9/13 SRH trying to make it work just for anatomical site
      int eemTypeId = entityOrEventMention.getTypeID();
      if (eemTypeId == CONST.NE_TYPE_ID_ANATOMICAL_SITE) {
          // 7/9/13 srh modified per tmiller so it's binary but not numeric feature
          //instance.add(new Feature("ENTITY_TYPE_" + entityOrEventMention.getTypeID()));
          instance.add(new Feature("ENTITY_TYPE_ANAT_SITE"));
      } /* This hurts recall more than it helps precision
View Full Code Here


        //Concept assertion = new Concept(jcas);

        org.mitre.medfacts.i2b2.annotation.AssertionAnnotation i2b2Assertion = (org.mitre.medfacts.i2b2.annotation.AssertionAnnotation)a;
        ConceptType conceptType = i2b2Assertion.getConceptType();

        IdentifiedAnnotation entityOrEventMention = null;
        if (conceptType.equals(ConceptType.TREATMENT))
        {
          entityOrEventMention = new EventMention(jcas);
        } else
        {
          entityOrEventMention = new EntityMention(jcas);
        }
       
        LineAndTokenPosition assertionStart = new LineAndTokenPosition();
        LineAndTokenPosition assertionEnd = new LineAndTokenPosition();
        assertionStart.setLine(a.getBegin().getLine());
        assertionStart.setTokenOffset(a.getBegin().getTokenOffset());
        assertionEnd.setLine(a.getEnd().getLine());
        assertionEnd.setTokenOffset(a.getEnd().getTokenOffset());
       
//        assertion.setBegin(converter.convert(assertionStart).getBegin());
//        assertion.setEnd(converter.convert(assertionEnd).getEnd() + 1);
//        assertion.setConceptType("PROBLEM");
//        assertion.addToIndexes();
       
        entityOrEventMention.setBegin(converter.convert(assertionStart).getBegin());
        entityOrEventMention.setEnd(converter.convert(assertionEnd).getEnd());
        entityOrEventMention.setConfidence(1.0f);
       
        FSArray ontologyConceptArray = ConceptLookup.reverseLookup(conceptType, jcas);
        entityOrEventMention.setOntologyConceptArr(ontologyConceptArray);
       
        //adjustAssertionAttributesByI2B2Convertion(entityOrEventMention, i2b2Assertion);
        AssertionAnalysisEngine.mapI2B2AssertionValueToCtakes(i2b2Assertion.getAssertionValue().toString().toLowerCase(), entityOrEventMention);
       
        entityOrEventMention.addToIndexes();
        logger.info("  end assertion");
      }
      logger.info("after assertions");
      writeXmi(cas,outFile);
    }
View Full Code Here

    System.err.println();
    return stats;
  }

  private static String formatRelation(BinaryTextRelation relation) {
    IdentifiedAnnotation arg1 = (IdentifiedAnnotation) relation.getArg1().getArgument();
    IdentifiedAnnotation arg2 = (IdentifiedAnnotation) relation.getArg2().getArgument();
    String text = arg1.getCAS().getDocumentText();
    int begin = Math.min(arg1.getBegin(), arg2.getBegin());
    int end = Math.max(arg1.getBegin(), arg2.getBegin());
    begin = Math.max(0, begin - 50);
    end = Math.min(text.length(), end + 50);
    return String.format(
        "%s(%s(type=%d), %s(type=%d)) in ...%s...",
        relation.getCategory(),
        arg1.getCoveredText(),
        arg1.getTypeID(),
        arg2.getCoveredText(),
        arg2.getTypeID(),
        text.substring(begin, end).replaceAll("[\r\n]", " "));
  }
View Full Code Here

                  for ( UmlsConcept umlsConcept : conceptSet ) {
                     conceptArr.set( arrIdx, umlsConcept );
                     arrIdx++;
                  }

                  IdentifiedAnnotation neAnnot;
                  final int conceptKey = conceptEntry.getKey();
                  if ( conceptKey == CONST.NE_TYPE_ID_DRUG ) {
                     neAnnot = new MedicationMention( jcas );
                  } else if ( conceptKey == CONST.NE_TYPE_ID_ANATOMICAL_SITE ) {
                      neAnnot = new AnatomicalSiteMention( jcas );
                  } else if ( conceptKey == CONST.NE_TYPE_ID_DISORDER ) {
                      neAnnot = new DiseaseDisorderMention( jcas );
                  } else if ( conceptKey == CONST.NE_TYPE_ID_FINDING ) {
                      neAnnot = new SignSymptomMention( jcas );
                  } else if ( conceptKey == CONST.NE_TYPE_ID_LAB ) {
                      neAnnot = new LabMention( jcas );
                  } else if ( conceptKey == CONST.NE_TYPE_ID_PROCEDURE ) {
                      neAnnot = new ProcedureMention( jcas );
                  } else {
                      neAnnot = new EntityMention( jcas );
                  }
                  neAnnot.setTypeID( conceptKey );
                  neAnnot.setBegin( neBegin );
                  neAnnot.setEnd( neEnd );
                  neAnnot.setDiscoveryTechnique( CONST.NE_DISCOVERY_TECH_DICT_LOOKUP );
                  neAnnot.setOntologyConceptArr( conceptArr );
                  neAnnot.addToIndexes();
               }
            }
         }
      } catch ( Exception e ) {
         throw new AnalysisEngineProcessException( e );
View Full Code Here

               final MetaDataHit mdh = lookupHit.getDictMetaDataHit();
               final String code = mdh.getMetaFieldValue( CODE_MF );
               validCodes.add( code );
            }
            final FSArray ocArr = createOntologyConceptArr( jcas, validCodes );
            IdentifiedAnnotation neAnnot = new MedicationMention( jcas ); // medication NEs are EventMention
            neAnnot.setTypeID( CONST.NE_TYPE_ID_DRUG );
            neAnnot.setBegin( neBegin );
            neAnnot.setEnd( neEnd );
            neAnnot.setDiscoveryTechnique( CONST.NE_DISCOVERY_TECH_DICT_LOOKUP );
            neAnnot.setOntologyConceptArr( ocArr );
            neAnnot.addToIndexes();
         } else {
            iv_logger.warn( "Filtered out: " + text );
         }
      }
   }
View Full Code Here

    //JCasUtil.indexCovering(jcas, IdentifiedAnnotation.class, this.ancestorAnnotationClass)
   
    Map<IdentifiedAnnotation, Collection<Zone>> coveringMap =
      JCasUtil.indexCovering(jcas, IdentifiedAnnotation.class, Zone.class);
   
    IdentifiedAnnotation targetEntityAnnotation = (IdentifiedAnnotation)targetAnnotation;
   
    Collection<Zone> zoneList = coveringMap.get(targetEntityAnnotation);
   
    if (zoneList == null || zoneList.isEmpty())
    {
View Full Code Here

               ocArrIdx++;
               codes.add( code );
            }
         }
        
         IdentifiedAnnotation neAnnot = new IdentifiedAnnotation(jcas);
         if ( typeId == CONST.NE_TYPE_ID_DRUG ) {
            neAnnot = new MedicationMention( jcas );
         } else if ( typeId == CONST.NE_TYPE_ID_ANATOMICAL_SITE ) {
             neAnnot = new AnatomicalSiteMention( jcas );
         } else if ( typeId == CONST.NE_TYPE_ID_DISORDER ) {
             neAnnot = new DiseaseDisorderMention( jcas );
         } else if ( typeId == CONST.NE_TYPE_ID_FINDING ) {
             neAnnot = new SignSymptomMention( jcas );
         } else if ( typeId == CONST.NE_TYPE_ID_LAB ) {
             neAnnot = new LabMention( jcas );
         } else if ( typeId == CONST.NE_TYPE_ID_PROCEDURE ) {
             neAnnot = new ProcedureMention( jcas );
         } else {
             neAnnot = new EntityMention( jcas );
         }
         final int neBegin = entry.getKey().__start;
         final int neEnd = entry.getKey().__end;
         neAnnot.setBegin( neBegin );
         neAnnot.setEnd( neEnd );
         neAnnot.setDiscoveryTechnique( CONST.NE_DISCOVERY_TECH_DICT_LOOKUP );
         neAnnot.setOntologyConceptArr( ocArr );
         neAnnot.setTypeID( typeId );
         neAnnot.addToIndexes();
      }
   }
View Full Code Here

  public void consumeHit(JCas jcas, Annotation focusAnnot, int scope, ContextHit ctxHit)
      throws AnalysisEngineProcessException {
   
    Integer status = (Integer) ctxHit.getMetaData(StatusContextAnalyzer.CTX_HIT_KEY_STATUS_TYPE);
    if (focusAnnot instanceof IdentifiedAnnotation) {
      IdentifiedAnnotation neAnnot = (IdentifiedAnnotation) focusAnnot;
      //TODO: currently status is an int in the old system.  Let's update this to a constant string?
      neAnnot.setUncertainty(status);
    }

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

*/
public class NegationContextHitConsumer extends NamedEntityContextHitConsumer implements ContextHitConsumer {
  public void consumeHit(JCas jcas, Annotation focusAnnot, int scope, ContextHit ctxHit)
      throws AnalysisEngineProcessException {
    if (focusAnnot instanceof IdentifiedAnnotation) {
      IdentifiedAnnotation neAnnot = (IdentifiedAnnotation) focusAnnot;
      neAnnot.setPolarity(-1);
    }

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

  private void createNewMention(JCas jCas, IdentifiedAnnotation mention,
      HashSet<Selector> hypothAttr) throws Throwable, IllegalAccessException {
   
    Constructor ctor = mention.getClass().getDeclaredConstructor(JCas.class);
    IdentifiedAnnotation m = (IdentifiedAnnotation) ctor.newInstance(jCas);
   
    m.setBegin(mention.getBegin());
    m.setEnd(mention.getEnd());
    for (Selector s : msg.keySet()) {
      if (!hypothAttr.contains(s)) {
        switch (s) {
        case CONDITIONAL:
          m.setConditional(mention.getConditional());
          break;
        case GENERIC:
          m.setGeneric(mention.getGeneric());
          break;
        case HISTORYOF:
          m.setHistoryOf(mention.getHistoryOf());
          break;
        case POLARITY:
          m.setPolarity(mention.getPolarity());
          break;
        case SUBJECT:
          m.setSubject(mention.getSubject());
          break;
        case UNCERTAINTY:
          m.setUncertainty(mention.getUncertainty());
          break;
        }
      }
    }
 
    m.addToIndexes(jCas);
  }
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.