Examples of StrengthAnnotation


Examples of org.apache.ctakes.drugner.type.StrengthAnnotation

        while (preTokenItr.hasNext())
        {
          StrengthToken mt = (StrengthToken) preTokenItr.next();
          int begOff = mt.getStartOffset();
          int endOff = mt.getEndOffset();
          StrengthAnnotation ma = new StrengthAnnotation(jcas, begOff, endOff);
          Iterator subStrengthItr = FSUtil.getAnnotationsIteratorInSpan(jcas, StrengthUnitAnnotation.type, begOff, endOff);
          if (subStrengthItr.hasNext() )
                ma.setEnd(((StrengthUnitAnnotation)subStrengthItr.next()).getBegin());
          ma.addToIndexes();
          // loadandAppend("./strengthTable.csv", ma.getCoveredText(),
          // true);

        }
//      }
      Set doseTokenSet = iv_dosagesFSM.execute(baseTokenList, formTokenSet,
          strengthTokenSet);
      Iterator dosTokenItr = doseTokenSet.iterator();
      Iterator formCheckItr = formTokenSet.iterator();
      Iterator strengthCheckItr = strengthTokenSet.iterator();
      boolean foundDosage = false;
      int begSegDose = 0, endSegDose = 0;

      while (dosTokenItr.hasNext())
      {
        DosageToken mt = (DosageToken) dosTokenItr.next();
        begSegDose = mt.getStartOffset();
        endSegDose = mt.getEndOffset();
        DosagesAnnotation ma = new DosagesAnnotation(jcas, begSegDose,
            endSegDose);

        ma.addToIndexes();

      }
      Set suffixTokenSet = iv_suffixFSM.execute(baseTokenList, strengthTokenSet);

      Iterator suffixTokenItr = suffixTokenSet.iterator();
      while (suffixTokenItr.hasNext())
      {
        SuffixStrengthToken mt = (SuffixStrengthToken) suffixTokenItr.next();
        SuffixStrengthAnnotation ma = new SuffixStrengthAnnotation(jcas, mt.getStartOffset(), mt.getEndOffset());
        ma.addToIndexes();
      }
      // This needs to be handled differently. But since I'm not sure if this feature will be utilized
      // I am going to leave 'as is' for now.

      Set routeTokenSet = iv_routeFSM.execute(baseTokenList);
      boolean foundRoute = false;
      Iterator routeTokenItr = routeTokenSet.iterator();
      int begSegRT = 0, endSegRT = 0;
      while (routeTokenItr.hasNext())
      {
        RouteToken mt = (RouteToken) routeTokenItr.next();
        begSegRT = mt.getStartOffset();
        endSegRT = mt.getEndOffset();
        RouteAnnotation ma = new RouteAnnotation(jcas, begSegRT, endSegRT);
        ma.setIntakeMethod(new Integer(mt.getFormMethod()).toString());
        ma.addToIndexes();

      }

      Set frequencyUnitTokenSet = iv_frequencyUnitFSM.execute(baseTokenList);
      boolean foundFrequencyUnit = false;
      Iterator frequencyUnitTokenItr = frequencyUnitTokenSet.iterator();
      int begSegFUT = 0, endSegFUT = 0;
      while (frequencyUnitTokenItr.hasNext())
      {

        FrequencyUnitToken fut = (FrequencyUnitToken) frequencyUnitTokenItr.next();

        begSegFUT = fut.getStartOffset();
        endSegFUT = fut.getEndOffset();
        FrequencyUnitAnnotation ma = new FrequencyUnitAnnotation(jcas,
            begSegFUT, endSegFUT);
        ma.setPeriod(new Float(fut.getFrequencyUnitQuantity()).floatValue());
        ma.addToIndexes();

      }
      // The frequencyFSM can take advantage of the frequencyUnit to
      // establish conditions via the override
      Set frequencyTokenSet = iv_frequencyFSM.execute(baseTokenList,
          frequencyUnitTokenSet, rangeTokenSet);
      boolean foundFrequency = false;
      Iterator frequencyTokenItr = frequencyTokenSet.iterator();
      int begSegFT = 0, endSegFT = 0;
      while (frequencyTokenItr.hasNext())
      {

        FrequencyToken ft = (FrequencyToken) frequencyTokenItr.next();
        begSegFT = ft.getStartOffset();
        endSegFT = ft.getEndOffset();
        FrequencyAnnotation ma = new FrequencyAnnotation(jcas, begSegFT,
            endSegFT);
        ma.addToIndexes();

      }

      /* Check again if confidence was found during frequency check */

      Set durationTokenSet = iv_durationFSM.execute(baseTokenList,
          rangeTokenSet);
      Iterator durationTokenItr = durationTokenSet.iterator();

      int begSegDU = 0, endSegDU = 0;
      while (durationTokenItr.hasNext())
      {
        DurationToken du = (DurationToken) durationTokenItr.next();
        begSegDU = du.getStartOffset();
        endSegDU = du.getEndOffset();
        DurationAnnotation ma = new DurationAnnotation(jcas, begSegDU, endSegDU);
        // dm.setDurationElement(jcas, begSegDU, endSegDU);
        ma.addToIndexes();
        // loadandAppend("./frequencyTable.csv", ma.getCoveredText(),
        // true);
      }

    } catch (Exception e)
View Full Code Here

Examples of org.apache.ctakes.drugner.type.StrengthAnnotation

          int holdStrengthBeginOffset = 0, holdStrengthEndOffset = 0;


          while (strengthItr.hasNext() && !onlyNeedOneStrength)
          {
            StrengthAnnotation sa = (StrengthAnnotation) strengthItr.next();

            if (holdStrengthBeginOffset != sa.getBegin()
                && holdStrengthEndOffset != sa.getEnd()
                && (relatedStatus != null))
            {

              double curStrengthValue = 0;

              int hyphenLocation = sa.getCoveredText().indexOf("-");
              String holdStrengthValue = sa.getCoveredText();

              if (hyphenLocation > 0)
              {
                holdStrengthValue = holdStrengthValue.substring(0, hyphenLocation);
              }

              int spaceLocation = holdStrengthValue.indexOf(" ");

              if (spaceLocation > 0)
              {
                holdStrengthValue = holdStrengthValue.substring(0, spaceLocation);
              }

              if (holdStrengthValue != null
                  && holdStrengthValue.compareTo("") != 0)
                curStrengthValue = new Double(dm.parseDoubleValue(holdStrengthValue)).doubleValue();
              boolean findLowValue = true;

              if (relatedStatus[0].compareTo(DrugChangeStatusToken.INCREASE) == 0)
              {
                if (curStrengthValue > strengthValue)
                {
                  strengthValue = curStrengthValue;
                  strengthText = dm.getStrengthElement();
                }
              } else if (relatedStatus[0].compareTo(DrugChangeStatusToken.DECREASE) == 0)
              {
                if (findLowValue)
                  strengthValue = curStrengthValue;
                if (curStrengthValue <= strengthValue)
                {
                  strengthValue = curStrengthValue;
                  strengthText = dm.getStrengthElement();
                }
                findLowValue = false;

              } else if (relatedStatus[0].compareTo(DrugChangeStatusToken.SUM) == 0)
              {

                strengthValue = curStrengthValue;
                strengthText = dm.getStrengthElement();
                // get first value found
              }
            } else
            {
              strengthText = dm.getStrengthElement();
              if (!maxExists)
                onlyNeedOneStrength = true;
              else if (maxOffsetEnd + 1 == sa.getBegin())
              {
                onlyNeedOneStrength = true;
                strengthText = sa.getCoveredText();
              }
            }

            holdStrengthBeginOffset = sa.getBegin();
            holdStrengthEndOffset = sa.getEnd();

          }
        }
        String doseText = null;
        if (!keepNoChangeStatus || (drugTokenAnt.getDosage() == null)) {
View Full Code Here

Examples of org.apache.ctakes.drugner.type.StrengthAnnotation

          lastLocation[1] = nea.getEnd();
        }
      }
    } else if (elementType == StrengthAnnotation.type) {
      while (neItr.hasNext() && wantMuliple) {
        StrengthAnnotation nea = (StrengthAnnotation) neItr.next();

        if (nea.getBegin()>=begin && nea.getEnd() <= end ) {
          if (!highest) wantMuliple = false;
          lastLocation[0] = nea.getBegin();
          lastLocation[1] = nea.getEnd();
        }
      }
    } else if (elementType == FrequencyAnnotation.type) {
      while (neItr.hasNext()&& wantMuliple) {
        FrequencyAnnotation nea = (FrequencyAnnotation) neItr.next();

        if (nea.getBegin()>=begin && nea.getEnd() <= end ) {
          if (!highest) wantMuliple = false;
          lastLocation[0] = nea.getBegin();
          lastLocation[1] = nea.getEnd();
        }      }
    } else if (elementType == FrequencyUnitAnnotation.type) {
      while (neItr.hasNext()&& wantMuliple) {
        FrequencyUnitAnnotation nea = (FrequencyUnitAnnotation) neItr.next();

        if (nea.getBegin()>=begin && nea.getEnd() <= end ) {
          if (!highest) wantMuliple = false;
          lastLocation[0] = nea.getBegin();
          lastLocation[1] = nea.getEnd();
        }      }
    } else if (elementType == DosagesAnnotation.type) {
      while (neItr.hasNext()&& wantMuliple) {
        DosagesAnnotation nea = (DosagesAnnotation) neItr.next();

        if (nea.getBegin()>=begin && nea.getEnd() <= end ) {
          if (!highest) wantMuliple = false;
          lastLocation[0] = nea.getBegin();
          lastLocation[1] = nea.getEnd();
        }
      }
    }

    return lastLocation;
View Full Code Here

Examples of org.apache.ctakes.drugner.type.StrengthAnnotation

          counter++;
        }
      }
    } else  if (elementType == StrengthAnnotation.type) {
      while (neItr.hasNext()) {
        StrengthAnnotation nea = (StrengthAnnotation) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (nea.getBegin()>=begin && nea.getEnd() <= end && (counter == || (counter> 0 && lastLocation[0] !=  location[counter - 1][0]))) {
          location[counter][0]= lastLocation[0];
          location[counter][1]= lastLocation[1];
          counter++;
        }
      }
    } else if (elementType == FrequencyAnnotation.type) {
      while (neItr.hasNext()) {
        FrequencyAnnotation nea = (FrequencyAnnotation) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (nea.getBegin()>=begin && nea.getEnd() <= end && (counter == || (counter> 0 && lastLocation[0] !=  location[counter - 1][0]))) {
          location[counter][0]= lastLocation[0];
          location[counter][1]= lastLocation[1];
          counter++;
        }      }
    } else if (elementType == FrequencyUnitAnnotation.type) {
      while (neItr.hasNext()) {
        FrequencyUnitAnnotation nea = (FrequencyUnitAnnotation) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (nea.getBegin()>=begin && nea.getEnd() <= end && (counter == || (counter> 0 && lastLocation[0] !=  location[counter - 1][0]))) {
          location[counter][0]= lastLocation[0];
          location[counter][1]= lastLocation[1];
          counter++;
        }
      }
    }    else if (elementType == DosagesAnnotation.type) {
      while (neItr.hasNext()) {
        DosagesAnnotation nea = (DosagesAnnotation) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (nea.getBegin()>=begin && nea.getEnd() <= end && (counter == || (counter> 0 && lastLocation[0] !=  location[counter - 1][0]))) {
          location[counter][0]= lastLocation[0];
          location[counter][1]= lastLocation[1];
          counter++;
        }
      }
    }else if (elementType == RouteAnnotation.type) {
      while (neItr.hasNext()) {
        RouteAnnotation nea = (RouteAnnotation) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (nea.getBegin()>=begin && nea.getEnd() <= end) {
          location[counter][0]= lastLocation[0];
          location[counter][1]= lastLocation[1];
          counter++;
        }
      }
    } else if (elementType == FormAnnotation.type) {
      while (neItr.hasNext()) {
        FormAnnotation nea = (FormAnnotation) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (nea.getBegin()>=begin && nea.getEnd() <= end && (counter == || (counter> 0 && lastLocation[0] !=  location[counter - 1][0]))) {
          location[counter][0]= lastLocation[0];
          location[counter][1]= lastLocation[1];
          counter++;
        }
      }
    }   
    else if (elementType == DurationAnnotation.type) {
      while (neItr.hasNext()) {
        DurationAnnotation nea = (DurationAnnotation) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (nea.getBegin()>=begin && nea.getEnd() <= end && (counter == || (counter> 0 && lastLocation[0] !=  location[counter - 1][0]))) {
          location[counter][0]= lastLocation[0];
          location[counter][1]= lastLocation[1];
          counter++;
        }
      }

    }
    else if (elementType == DrugChangeStatusAnnotation.type) {
      while (neItr.hasNext()) {
        DrugChangeStatusAnnotation nea = (DrugChangeStatusAnnotation) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (nea.getBegin()>=begin && nea.getEnd() <= end && (counter == || (counter> 0 && lastLocation[0] !=  location[counter - 1][0]))) {
          location[counter][0]= lastLocation[0];
          location[counter][1]= lastLocation[1];
          counter++;
        }
      }

    } else if (elementType == MedicationMention.type) {
      while (neItr.hasNext()) {
        MedicationMention nea = (MedicationMention) neItr.next();
        if(nea.getTypeID()==1 || nea.getTypeID()==0) {
          lastLocation[0]= nea.getBegin();
          lastLocation[1] = nea.getEnd();
          if ((counter == 0 || lastLocation[0] != location[counter-1][0]) && (nea.getBegin()>=begin && nea.getEnd() <= end)) {
            location[counter][0]= lastLocation[0];
            location[counter][1]= lastLocation[1];
            counter++;
          }

        }
      }
    } else if (elementType == PunctuationToken.type) {
      while (neItr.hasNext()) {
        boolean foundPair = false;
        PunctuationToken nea = (PunctuationToken) neItr.next();
        if (nea.getCoveredText().compareTo("(")==0)
          lastLocation[0] = nea.getBegin();
        else if (nea.getCoveredText().compareTo(")")==0) {
          lastLocation[1] = nea.getEnd();
          foundPair = true;
        }
        if (nea.getBegin()>=begin && nea.getEnd() <= end && foundPair && (counter == || (counter> 0 && lastLocation[0] !=  location[counter - 1][0]))) {
          location[counter][0]= lastLocation[0];
          location[counter][1]= lastLocation[1];
          counter++;
        }
      }
View Full Code Here

Examples of org.apache.ctakes.drugner.type.StrengthAnnotation

    // Iterator neItr= indexes.getAnnotationIndex(elementType).iterator();
    int numElements = 0;
    neItr = FSUtil.getAnnotationsIteratorInSpan(jcas,
        StrengthAnnotation.type, begin, end);
    while (neItr.hasNext()) {
      StrengthAnnotation nea = (StrengthAnnotation) neItr.next();
      // if(nea.getBegin()>=begin && nea.getEnd()<=end) {
      numElements++;

    }
    neItr = FSUtil.getAnnotationsIteratorInSpan(jcas,
View Full Code Here

Examples of org.apache.ctakes.drugner.type.StrengthAnnotation

    int [] lastLocation =  {-1,-1};
    int counter = 0;
    if (elementType == StrengthAnnotation.type) {
      int holdBeginElement = 0, holdEndElement = 0;
      while (neItr.hasNext()) {
        StrengthAnnotation nea = (StrengthAnnotation) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (holdBeginElement < nea.getBegin() && nea.getBegin()>=begin && nea.getEnd() <= end && nea.getEnd() > holdEndElement) {
          holdBeginElement = location[counter][0]= lastLocation[0];
          holdEndElement = location[counter][1]= lastLocation[1];
          counter++;
        }
      }
    } else if (elementType == FrequencyAnnotation.type) {
      int holdBeginElement = 0, holdEndElement = 0;
      while (neItr.hasNext()) {
        FrequencyAnnotation nea = (FrequencyAnnotation) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (holdBeginElement < nea.getBegin() && nea.getBegin()>=begin && nea.getEnd() <= end && nea.getEnd() > holdEndElement) {
          holdBeginElement = location[counter][0]= lastLocation[0];
          holdEndElement = location[counter][1]= lastLocation[1];
          counter++;
        }      }
    } else if (elementType == FrequencyUnitAnnotation.type) {
      int holdBeginElement = 0, holdEndElement = 0;
      while (neItr.hasNext()) {
        FrequencyUnitAnnotation nea = (FrequencyUnitAnnotation) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (holdBeginElement < nea.getBegin() && nea.getBegin()>=begin && nea.getEnd() <= end && nea.getEnd() > holdEndElement) {
          holdBeginElement = location[counter][0]= lastLocation[0];
          holdEndElement = location[counter][1]= lastLocation[1];
          counter++;
        }
      }
    }    else if (elementType == DosagesAnnotation.type) {
      int holdBeginElement = 0, holdEndElement = 0;
      while (neItr.hasNext()) {
        DosagesAnnotation nea = (DosagesAnnotation) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (holdBeginElement < nea.getBegin() && nea.getBegin()>=begin && nea.getEnd() <= end && nea.getEnd() > holdEndElement) {
          holdBeginElement = location[counter][0]= lastLocation[0];
          holdEndElement = location[counter][1]= lastLocation[1];
          counter++;
        }
      }
    }else if (elementType == RouteAnnotation.type) {
      int holdBeginElement = 0, holdEndElement = 0;
      while (neItr.hasNext()) {
        RouteAnnotation nea = (RouteAnnotation) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (holdBeginElement < nea.getBegin() && nea.getBegin()>=begin && nea.getEnd() <= end && nea.getEnd() > holdEndElement) {
          holdBeginElement = location[counter][0]= lastLocation[0];
          holdEndElement = location[counter][1]= lastLocation[1];
          counter++;
        }
      }
    } else if (elementType == FormAnnotation.type) {
      int holdBeginElement = 0, holdEndElement = 0;
      while (neItr.hasNext()) {
        FormAnnotation nea = (FormAnnotation) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (holdBeginElement < nea.getBegin() && nea.getBegin()>=begin && nea.getEnd() <= end && nea.getEnd() > holdEndElement) {
          holdBeginElement = location[counter][0]= lastLocation[0];
          holdEndElement = location[counter][1]= lastLocation[1];
          counter++;
        }
      }
    }   
    else if (elementType == DurationAnnotation.type) {
      int holdBeginElement = 0, holdEndElement = 0;
      while (neItr.hasNext()) {
        DurationAnnotation nea = (DurationAnnotation) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (holdBeginElement < nea.getBegin() && nea.getBegin()>=begin && nea.getEnd() <= end && nea.getEnd() > holdEndElement) {
          holdBeginElement = location[counter][0]= lastLocation[0];
          holdEndElement = location[counter][1]= lastLocation[1];
          counter++;
        }
      }

    }
    else if (elementType == NewlineToken.type) {
      int holdBeginElement = 0;
      while (neItr.hasNext()) {
        NewlineToken nea = (NewlineToken) neItr.next();
        lastLocation[0] = nea.getBegin();
        lastLocation[1] = nea.getEnd();
        if (holdBeginElement < nea.getBegin() && nea.getBegin()>=begin && nea.getEnd() <= end) {
          holdBeginElement = location[counter][0]= lastLocation[0];
          location[counter][1]= lastLocation[1];
          counter++;
        }
      }

    } else if (elementType == MedicationMention.type) {
      int holdEndElement = 0;
      while (neItr.hasNext()) {
        MedicationMention nea = (MedicationMention) neItr.next();
        if(nea.getTypeID()==1 || nea.getTypeID()==0) {
          lastLocation[0]= nea.getBegin();
          lastLocation[1] = nea.getEnd();
          if ((counter == 0 || lastLocation[0] != location[counter-1][0]) && (nea.getBegin()>=begin && nea.getEnd() <= end)) {
            location[counter][0]= lastLocation[0];
            holdEndElement = location[counter][1] = lastLocation[1];
            counter++;
          } else if (counter > 0 && holdEndElement > lastLocation[1]) {
            holdEndElement = location[counter-1][1] = lastLocation[1];
          }

        }
      }
    } else if (elementType == PunctuationToken.type) {
      while (neItr.hasNext()) {
        int holdBeginElement = 0;
        boolean foundPair = false;
        PunctuationToken nea = (PunctuationToken) neItr.next();
        if (nea.getCoveredText().compareTo("(")==0 || nea.getCoveredText().compareTo("[")==0)
          lastLocation[0] = nea.getBegin();
        else if (nea.getCoveredText().compareTo(")")==0 || nea.getCoveredText().compareTo("]")==0) {
          lastLocation[1] = nea.getEnd();
          foundPair = true;
        }
        if (holdBeginElement < nea.getBegin() && nea.getBegin()>=begin && nea.getEnd() <= end && foundPair) {
          location[counter][0]= lastLocation[0];
          location[counter][1]= lastLocation[1];
          counter++;
        }
      }
View Full Code Here

Examples of org.apache.ctakes.drugner.type.StrengthAnnotation

        setStrengthUnitElement(focusToken.getCoveredText(),
            focusToken.getBegin(), focusToken.getEnd());
      }
      Iterator strengthTokenItr = FSUtil.getAnnotationsIteratorInSpan(jcas, StrengthAnnotation.type, beginPos, endPos);
      while (strengthTokenItr.hasNext()){
        StrengthAnnotation focusToken = (StrengthAnnotation) strengthTokenItr.next();
        

            String localStrength = null;
            if ((localStrength = findStrengthElement(jcas, focusToken
                .getBegin(), focusToken.getEnd())) == null) {
              strength = new StrengthElement(focusToken.getCoveredText(),
                  focusToken.getBegin(), focusToken.getEnd());
            } else {
              if (strength != null) {
                // check for range and compare
                int spacePosition = strength.getStrengthMention()
                    .indexOf(" ");
                int spacePos = localStrength
                .indexOf(" ");
                if (spacePosition > 0 && spacePos > 0
                    && parseDoubleValue(strength
                        .getStrengthMention().substring(0,
                            spacePosition)) < parseDoubleValue(localStrength
                        .substring(0, localStrength
                            .indexOf(" ")))&& findMaxValue == true) {
                  setStrengthElement(localStrength, focusToken
                      .getBegin(), focusToken.getEnd());
                } else {
                  String stringRange = strength.getStrengthMention();
                  int hyphPosition = 0;
                  if ((stringRange.length() > 0)
                      && (stringRange.indexOf('-') > 0)) {
                    hyphPosition = stringRange.indexOf('-');
                    Double firstValue = new Double(
                        parseDoubleValue(stringRange
                            .subSequence(0, hyphPosition)));
                    Double secondValue = new Double(
                        parseDoubleValue(stringRange
                            .substring(hyphPosition + 2)));
                    if (firstValue.doubleValue() >= secondValue
                        .doubleValue() && findMaxValue == true) {
                      setStrengthElement(firstValue.toString(),
                          focusToken.getBegin(), focusToken
                              .getEnd());
                    } else {
                      setStrengthElement(firstValue.toString(),
                          focusToken.getBegin(), focusToken
                              .getEnd());
                    }
                  }
                }
              } else if ((localStrength.length() > 0)
                  && (localStrength.indexOf('-') > 0)) {

                int hyphPosition = 0;

                hyphPosition = localStrength.indexOf('-');
                Double firstValue = new Double(
                    parseDoubleValue(localStrength.subSequence(0,
                        hyphPosition)));
                Double secondValue = new Double(
                    parseDoubleValue(localStrength
                        .substring(hyphPosition + 2)));
                if (firstValue.doubleValue() >= secondValue
                    .doubleValue() && findMaxValue == true) {
                  setStrengthElement(firstValue.toString(),
                      focusToken.getBegin(), focusToken.getEnd());
                } else {
                  setStrengthElement(firstValue.toString(),
                      focusToken.getBegin(), focusToken.getEnd());
                }

                setStrengthElement(localStrength,
                    focusToken.getBegin(), focusToken.getEnd());
              } else {
                setStrengthElement(localStrength,
                    focusToken.getBegin(), focusToken.getEnd());
              }
            }
      }
      Iterator formTokenItr = FSUtil.getAnnotationsIteratorInSpan(jcas, FormAnnotation.type, beginPos, endPos);
      while (formTokenItr.hasNext()){
        FormAnnotation focusToken = (FormAnnotation) formTokenItr.next();
        String localForm = null;
        if ((localForm = findFormElement(jcas, focusToken.getBegin(),
            focusToken.getEnd())) == null) {
          form = new FormElement(focusToken.getCoveredText(),
              focusToken.getBegin(), focusToken.getEnd());
        } else {
          setFormElement(localForm, focusToken.getBegin(), focusToken
              .getEnd());
        }
      }
      Iterator routeTokenItr = FSUtil.getAnnotationsIteratorInSpan(jcas, RouteAnnotation.type, beginPos, endPos);
      while (routeTokenItr.hasNext()){
        RouteAnnotation focusToken = (RouteAnnotation) routeTokenItr.next();
        String localRoute = null;
        if ((localRoute = findRouteElement(jcas, focusToken.getBegin(),
            focusToken.getEnd())) == null) {
          route = new RouteElement(focusToken.getCoveredText(),
              focusToken.getBegin(), focusToken.getEnd());
        } else {
          setRouteElement(localRoute, focusToken.getBegin(),
              focusToken.getEnd());
        }
      }
      Iterator durationTokenItr = FSUtil.getAnnotationsIteratorInSpan(jcas, DurationAnnotation.type, beginPos, endPos);
      while (durationTokenItr.hasNext()){
        DurationAnnotation focusToken = (DurationAnnotation) durationTokenItr.next();
        String localDuration = null;
        if ((localDuration = findDurationElement(jcas, focusToken
            .getBegin(), focusToken.getEnd())) == null) {
          duration = new DurationElement(focusToken.getCoveredText(),
              focusToken.getBegin(), focusToken.getEnd());
        } else {
          setDurationElement(localDuration, focusToken.getBegin(),
              focusToken.getEnd());
        }
      }

     
 
View Full Code Here

Examples of org.apache.ctakes.drugner.type.StrengthAnnotation

  private String findStrengthElement(JCas jcas, int beginOffset, int endOffset) {

    Iterator firItr = FSUtil.getAnnotationsIteratorInSpan(jcas,
        StrengthAnnotation.type, beginOffset, endOffset + 1);
    while (firItr.hasNext()) {
      StrengthAnnotation dcsa = (StrengthAnnotation) firItr.next();
      String strength = dcsa.getCoveredText();
            int findHyph = strength.indexOf('-');
            if (findHyph > 0){
              // large value in the range
              strength = strength.substring(findHyph+1);
            }
      if (dcsa.getBegin() == beginOffset) {

        return parseRegex(strength);
      }
    }
View Full Code Here

Examples of org.apache.ctakes.drugner.type.StrengthAnnotation

        while (preTokenItr.hasNext())
        {
          StrengthToken mt = (StrengthToken) preTokenItr.next();
          int begOff = mt.getStartOffset();
          int endOff = mt.getEndOffset();
          StrengthAnnotation ma = new StrengthAnnotation(jcas, begOff, endOff);
          Iterator subStrengthItr = FSUtil.getAnnotationsIteratorInSpan(jcas, StrengthUnitAnnotation.type, begOff, endOff);
          if (subStrengthItr.hasNext() )
                ma.setEnd(((StrengthUnitAnnotation)subStrengthItr.next()).getBegin());
          ma.addToIndexes();
          // loadandAppend("./strengthTable.csv", ma.getCoveredText(),
          // true);

        }
//      }
      Set doseTokenSet = iv_dosagesFSM.execute(baseTokenList, formTokenSet,
          strengthTokenSet);
      Iterator dosTokenItr = doseTokenSet.iterator();
      Iterator formCheckItr = formTokenSet.iterator();
      Iterator strengthCheckItr = strengthTokenSet.iterator();
      boolean foundDosage = false;
      int begSegDose = 0, endSegDose = 0;

      while (dosTokenItr.hasNext())
      {
        DosageToken mt = (DosageToken) dosTokenItr.next();
        begSegDose = mt.getStartOffset();
        endSegDose = mt.getEndOffset();
        DosagesAnnotation ma = new DosagesAnnotation(jcas, begSegDose,
            endSegDose);

        ma.addToIndexes();

      }
      Set suffixTokenSet = iv_suffixFSM.execute(baseTokenList, strengthTokenSet);

      Iterator suffixTokenItr = suffixTokenSet.iterator();
      while (suffixTokenItr.hasNext())
      {
        SuffixStrengthToken mt = (SuffixStrengthToken) suffixTokenItr.next();
        SuffixStrengthAnnotation ma = new SuffixStrengthAnnotation(jcas, mt.getStartOffset(), mt.getEndOffset());
        ma.addToIndexes();
      }
      // This needs to be handled differently. But since I'm not sure if this feature will be utilized
      // I am going to leave 'as is' for now.

      Set routeTokenSet = iv_routeFSM.execute(baseTokenList);
      boolean foundRoute = false;
      Iterator routeTokenItr = routeTokenSet.iterator();
      int begSegRT = 0, endSegRT = 0;
      while (routeTokenItr.hasNext())
      {
        RouteToken mt = (RouteToken) routeTokenItr.next();
        begSegRT = mt.getStartOffset();
        endSegRT = mt.getEndOffset();
        RouteAnnotation ma = new RouteAnnotation(jcas, begSegRT, endSegRT);
        ma.setIntakeMethod(new Integer(mt.getFormMethod()).toString());
        ma.addToIndexes();

      }

      Set frequencyUnitTokenSet = iv_frequencyUnitFSM.execute(baseTokenList);
      boolean foundFrequencyUnit = false;
      Iterator frequencyUnitTokenItr = frequencyUnitTokenSet.iterator();
      int begSegFUT = 0, endSegFUT = 0;
      while (frequencyUnitTokenItr.hasNext())
      {

        FrequencyUnitToken fut = (FrequencyUnitToken) frequencyUnitTokenItr.next();

        begSegFUT = fut.getStartOffset();
        endSegFUT = fut.getEndOffset();
        FrequencyUnitAnnotation ma = new FrequencyUnitAnnotation(jcas,
            begSegFUT, endSegFUT);
        ma.setPeriod(new Float(fut.getFrequencyUnitQuantity()).floatValue());
        ma.addToIndexes();

      }
      // The frequencyFSM can take advantage of the frequencyUnit to
      // establish conditions via the override
      Set frequencyTokenSet = iv_frequencyFSM.execute(baseTokenList,
          frequencyUnitTokenSet, rangeTokenSet);
      boolean foundFrequency = false;
      Iterator frequencyTokenItr = frequencyTokenSet.iterator();
      int begSegFT = 0, endSegFT = 0;
      while (frequencyTokenItr.hasNext())
      {

        FrequencyToken ft = (FrequencyToken) frequencyTokenItr.next();
        begSegFT = ft.getStartOffset();
        endSegFT = ft.getEndOffset();
        FrequencyAnnotation ma = new FrequencyAnnotation(jcas, begSegFT,
            endSegFT);
        ma.addToIndexes();

      }

      /* Check again if confidence was found during frequency check */

      Set durationTokenSet = iv_durationFSM.execute(baseTokenList,
          rangeTokenSet);
      Iterator durationTokenItr = durationTokenSet.iterator();

      int begSegDU = 0, endSegDU = 0;
      while (durationTokenItr.hasNext())
      {
        DurationToken du = (DurationToken) durationTokenItr.next();
        begSegDU = du.getStartOffset();
        endSegDU = du.getEndOffset();
        DurationAnnotation ma = new DurationAnnotation(jcas, begSegDU, endSegDU);
        // dm.setDurationElement(jcas, begSegDU, endSegDU);
        ma.addToIndexes();
        // loadandAppend("./frequencyTable.csv", ma.getCoveredText(),
        // true);
      }

    } catch (Exception e)
View Full Code Here

Examples of org.apache.ctakes.drugner.type.StrengthAnnotation

          int holdStrengthBeginOffset = 0, holdStrengthEndOffset = 0;


          while (strengthItr.hasNext() && !onlyNeedOneStrength)
          {
            StrengthAnnotation sa = (StrengthAnnotation) strengthItr.next();

            if (holdStrengthBeginOffset != sa.getBegin()
                && holdStrengthEndOffset != sa.getEnd()
                && (relatedStatus != null))
            {

              double curStrengthValue = 0;

              int hyphenLocation = sa.getCoveredText().indexOf("-");
              String holdStrengthValue = sa.getCoveredText();

              if (hyphenLocation > 0)
              {
                holdStrengthValue = holdStrengthValue.substring(0, hyphenLocation);
              }

              int spaceLocation = holdStrengthValue.indexOf(" ");

              if (spaceLocation > 0)
              {
                holdStrengthValue = holdStrengthValue.substring(0, spaceLocation);
              }

              if (holdStrengthValue != null
                  && holdStrengthValue.compareTo("") != 0)
                curStrengthValue = new Double(dm.parseDoubleValue(holdStrengthValue)).doubleValue();
              boolean findLowValue = true;

              if (relatedStatus[0].compareTo(DrugChangeStatusToken.INCREASE) == 0)
              {
                if (curStrengthValue > strengthValue)
                {
                  strengthValue = curStrengthValue;
                  strengthText = dm.getStrengthElement();
                }
              } else if (relatedStatus[0].compareTo(DrugChangeStatusToken.DECREASE) == 0)
              {
                if (findLowValue)
                  strengthValue = curStrengthValue;
                if (curStrengthValue <= strengthValue)
                {
                  strengthValue = curStrengthValue;
                  strengthText = dm.getStrengthElement();
                }
                findLowValue = false;

              } else if (relatedStatus[0].compareTo(DrugChangeStatusToken.SUM) == 0)
              {

                strengthValue = curStrengthValue;
                strengthText = dm.getStrengthElement();
                // get first value found
              }
            } else
            {
              strengthText = dm.getStrengthElement();
              if (!maxExists)
                onlyNeedOneStrength = true;
              else if (maxOffsetEnd + 1 == sa.getBegin())
              {
                onlyNeedOneStrength = true;
                strengthText = sa.getCoveredText();
              }
            }

            holdStrengthBeginOffset = sa.getBegin();
            holdStrengthEndOffset = sa.getEnd();

          }
        }
        String doseText = null;
        if (!keepNoChangeStatus || (drugTokenAnt.getDosage() == null)) {
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.