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

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


    JFSIndexRepository indexes = jcas.getJFSIndexRepository();
        Iterator neItr= indexes.getAnnotationIndex(IdentifiedAnnotation.type).iterator();
        List<IdentifiedAnnotation> l = new ArrayList<IdentifiedAnnotation>();
       
        while (neItr.hasNext()) {
          IdentifiedAnnotation nea = (IdentifiedAnnotation) neItr.next();
          if(setionsToIgnore.contains(nea.getSegmentID())) continue;
          if(nea.getPolarity()==-1) continue; //negated
                  
          boolean addFlag = true;
                   
          if(nea.getTypeID()==3 || nea.getTypeID()==2) { //signs/symptoms or diseases/disorders
            //add the longest only (also remove the duplicate)
            if(l.size()==0) l.add(nea);
            else {             
              for(int i=0; i<l.size(); i++) {
                IdentifiedAnnotation x = (IdentifiedAnnotation) l.get(i);
                int j = SEUtil.contains(nea.getBegin(), nea.getEnd(),
                      x.getBegin(), x.getEnd());
                if(j==1) {
                  l.remove(i);
                  i--;
                }
                else if(j==2) {
View Full Code Here


  private List<PotentialSideEffect> getPotentialSideEffects(JCas jcas) {   
        List<IdentifiedAnnotation> l = getSideEffectNEs(jcas);       
        List<PotentialSideEffect> ll = new ArrayList<PotentialSideEffect>();
       
        for(int i=0; i<l.size(); i++) {
          IdentifiedAnnotation ne = (IdentifiedAnnotation) l.get(i);
        int[] senSpan = SEUtil.getSentenceSpanContainingGivenSpan(jcas, ne.getBegin(), ne.getEnd());
        String sentence = SEUtil.getSentenceTextContainingGivenSpan(jcas, ne.getBegin(), ne.getEnd()).trim();
        boolean foundDrug = false;
       
        //check the same sentence if it contains drug
        Iterator neIter = FSUtil.getAnnotationsInSpanIterator(
            jcas, IdentifiedAnnotation.type, senSpan[0], senSpan[1]+1);
       
        while(neIter.hasNext()) {
          IdentifiedAnnotation n = (IdentifiedAnnotation) neIter.next();
          if(n.getTypeID()==1) { //drug           
            PotentialSideEffect pse = new PotentialSideEffect();
              pse.ne = ne;
              pse.sentence = sentence;
              pse.senBegin = senSpan[0];
              pse.senEnd = senSpan[1];
              pse.drug = n;
              ll.add(pse);
            foundDrug = true;
          }
        }
       
        // if drug is not found in the same sentence, check the previous sentence
        if(!foundDrug && !ne.getSegmentID().equals("20105")) {
          int num = SEUtil.getSentenceNumContainingGivenSpan(jcas, ne.getBegin(), ne.getEnd());
          num = (num>0) ? num-1 : num;         
          int [] previousSenSpan = SEUtil.getSentenceSpanOfGivenSentenceNum(jcas, num);
         
          //only if they are in the same line
          if(SEUtil.isSpanInSameLine(jcas, previousSenSpan[0], senSpan[1])) {
            neIter = FSUtil.getAnnotationsInSpanIterator(jcas, IdentifiedAnnotation.type,
                previousSenSpan[0], previousSenSpan[1]+1);

            while(neIter.hasNext()) {
              IdentifiedAnnotation n = (IdentifiedAnnotation) neIter.next();
              if(n.getTypeID()==1) { //drug
                PotentialSideEffect pse = new PotentialSideEffect();
                pse.ne = ne;
                pse.sentence = SEUtil.getSentenceTextContainingGivenSpan(
                    jcas, n.getBegin(), n.getEnd())
                    + " " + sentence;
                pse.senBegin = previousSenSpan[0];
                pse.senEnd = senSpan[1];
                pse.drug = n;
                ll.add(pse);
View Full Code Here

   
    //if sideEffectWord is negated return false
    Iterator neIter = FSUtil.getAnnotationsInSpanIterator(
        jcas, IdentifiedAnnotation.type, pse.senBegin, pse.senEnd+1);
    while(neIter.hasNext()) {
      IdentifiedAnnotation ne = (IdentifiedAnnotation) neIter.next();
      if(ne.getCoveredText().replace('-',' ').toLowerCase().trim()
          .indexOf(pm.mat.group(1))!=-1 && ne.getPolarity()==-1)
        return false;     
    }
       
    return true;
  }
View Full Code Here

    Iterator neIter = FSUtil.getAnnotationsInSpanIterator(
             jcas, IdentifiedAnnotation.type, pse.senBegin, pse.senEnd+1);
   
    //NEs are stored in CAS in order of offsets so using replaceFirst() works
    while(neIter.hasNext()) {
      IdentifiedAnnotation nea = (IdentifiedAnnotation) neIter.next();
      if(nea.getTypeID()==1) {
        String drug="";
        if(nea.getBegin()==pse.drug.getBegin() && nea.getEnd()==pse.drug.getEnd())
          drug = "<@DRUG>";
        else
          drug = "<DRUG>";
        //some named entity contain special char used in RegEx (eg, ')')
        str = str.replaceFirst(
            nea.getCoveredText().replaceAll("[\\<\\(\\[\\{\\\\^\\-\\=\\$\\!\\|\\]\\}\\)\\?\\*\\+\\.\\>]", "").toLowerCase(),drug);
      }
      else if(nea.getTypeID()==2 || nea.getTypeID()==3) {
        String ps="";
        if(nea.getBegin()==pse.ne.getBegin() && nea.getEnd()==pse.ne.getEnd())
          ps = "<@PSE>";
        else
          ps = "<PSE>";
        str = str.replaceFirst(
            nea.getCoveredText().replaceAll("[\\<\\(\\[\\{\\\\^\\-\\=\\$\\!\\|\\]\\}\\)\\?\\*\\+\\.\\>]", "").toLowerCase(),ps);
      }     
    }
       
    return str.trim();
  }
View Full Code Here

      ApiConcept originalConcept = apiConceptList.get(currentIndex);

      Concept associatedConcept = (Concept) indexer
          .lookupByAddress(originalConcept.getExternalId());
      int entityAddress = associatedConcept.getOriginalEntityExternalId();
      IdentifiedAnnotation annotation = (IdentifiedAnnotation) indexer
          .lookupByAddress(entityAddress);

      // possible values for currentAssertionType:
      // present
      // absent
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.