Examples of StrengthUnitAnnotation


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

        WordToken we = null;
        Object mt = (ObjectmeasurementTokenItr.next();
        if (mt instanceof  StrengthUnitToken) {
          // StrengthUnitToken mt = (StrengthUnitToken) measurementTokenItr.next();
          int begSeg = ((StrengthUnitToken) mt).getStartOffset(), endSeg = ((StrengthUnitToken) mt).getEndOffset();
          StrengthUnitAnnotation ma = new StrengthUnitAnnotation(jcas, begSeg, endSeg);
          ma.addToIndexes();
        } else {
          int begSeg = ((StrengthUnitCombinedToken) mt).getStartOffset(), endSeg = ((StrengthUnitCombinedToken) mt).getEndOffset();
          StrengthUnitAnnotation ma = new StrengthUnitAnnotation(jcas, begSeg, endSeg);
          ma.setBegin(findTextualStringOffset(ma.getCoveredText()) + begSeg);
          ma.addToIndexes();
        }
        //TODO: Does this need to be commented out? Created Strength       
      }

//      Set decTokenSet = null;
//      {
//        decTokenSet = iv_strengthFSM.execute(baseTokenList, decimalTokenSet,
//            fractionTokenSet);
//        Iterator decTokenItr = decTokenSet.iterator();
//
//        while (decTokenItr.hasNext())
//        {
//          StrengthToken mt = (StrengthToken) decTokenItr.next();
//          StrengthAnnotation ma = new StrengthAnnotation(jcas, mt
//              .getStartOffset(), mt.getEndOffset());
//          ma.addToIndexes();
//          // loadandAppend("./strengthTable.csv", ma.getCoveredText(),
//          // true);
//
//        }
//      }

      Set formTokenSet = iv_formFSM.execute(baseTokenList,
          /* decimalTokenSet */new HashSet());
      Iterator formTokenItr = formTokenSet.iterator();

      while (formTokenItr.hasNext())
      {
        FormToken mt = (FormToken) formTokenItr.next();
        FormAnnotation ma = new FormAnnotation(jcas, mt.getStartOffset(), mt.getEndOffset());

        ma.addToIndexes();
        // if (defaultNE != null && defaultNE.getCoveredText() != null)
        // defaultNE.setForm(ma.getCoveredText());

      }

      // last run checks for numbers (text or actual) in front of dosage
      // info and see how we align w/ the ne if they exist to determine
      // confidence factoring
      //      if (!doseConfidence && decTokenSet != null)
//      {
        Set preTokenSet = iv_strengthFSM.execute(baseTokenList, strengthTokenSet, fractionTokenSet);
        Iterator preTokenItr = preTokenSet.iterator();

        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.StrengthUnitAnnotation

    Iterator neItr = indexes.getAnnotationIndex(elementType).iterator();//FSUtil.getAnnotationsInSpanIterator(jcas, elementType, begin, end);
    int [] lastLocation =  {-1,-1};
    boolean wantMuliple = true;
    if (elementType == StrengthUnitAnnotation.type) {
      while (neItr.hasNext() && wantMuliple) {
        StrengthUnitAnnotation nea = (StrengthUnitAnnotation) neItr.next();

        if (nea.getBegin()>=begin && nea.getEnd() <= end ) {
          if (!highest) wantMuliple = false;
          lastLocation[0] = nea.getBegin();
          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.StrengthUnitAnnotation

    Iterator neItr = indexes.getAnnotationIndex(elementType).iterator();//FSUtil.getAnnotationsInSpanIterator(jcas, elementType, begin, end);
    int [] lastLocation =  {-1,-1};
    int counter = 0;
    if (elementType == StrengthUnitAnnotation.type) {
      while (neItr.hasNext()) {
        StrengthUnitAnnotation nea = (StrengthUnitAnnotation) 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 == 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 == MedicationEventMention.type) {
      while (neItr.hasNext()) {
        MedicationEventMention nea = (MedicationEventMention) 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
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.