Package org.apache.ctakes.padtermspotter.type

Examples of org.apache.ctakes.padtermspotter.type.SubSection


    JFSIndexRepository indexes = jcas.getJFSIndexRepository();
    Iterator<?> secItr = indexes.getAnnotationIndex(SubSection.type).iterator();
     
    while(secItr.hasNext())
    {
      SubSection sa = (SubSection)secItr.next();
      if(sa.getBegin() <= begin && end <= sa.getEnd())
        return String.valueOf(sa.getParentSectionId());
      //if NE spans 2 or more sentences, use the begining sentence
      else if(sa.getBegin() <= begin && begin < sa.getEnd())
        return String.valueOf(sa.getParentSectionId());
    }
    return "-1";
  }
View Full Code Here


    JFSIndexRepository indexes = jcas.getJFSIndexRepository();
    Iterator<?> secItr = indexes.getAnnotationIndex(SubSection.type).iterator();
     
    while(secItr.hasNext())
    {
      SubSection sa = (SubSection)secItr.next();

      if (sa.getStatus() == 1 & sa.getCoveredText().startsWith(revisionHeader) ) {
        return sa.getSubSectionBodyBegin();
      }
     
    }
    return 0;
  }
View Full Code Here

    JFSIndexRepository indexes = jcas.getJFSIndexRepository();
    Iterator<?> secItr = indexes.getAnnotationIndex(SubSection.type).iterator();
     
    while(secItr.hasNext())
    {
      SubSection sa = (SubSection) secItr.next();
      // Don't look in sections after a cut off revision point
      if (cutOff == || (cutOff > 0 && (sa.getSubSectionBodyBegin() < cutOff))) {
        // since entire subsections will be used to determine if
        // location is used remove mentions overlapping in the header
        if (sa.getSubSectionHeaderBegin() <= begin
            && sa.getSubSectionHeaderEnd() >= end)
          return "1";

        else if (sa.getBegin() <= begin && end <= sa.getEnd()) {
          if (sa.getStatus() == 1
              & sa.getCoveredText().startsWith(indicationsHeader)
              && sa.getBegin() > maxSubsectionSize)
            return "-1";

          return String.valueOf(sa.getStatus());
        }
        // if NE spans 2 or more sentences, use the beginning sentence
        else if (sa.getBegin() <= begin && begin < sa.getEnd())
          return String.valueOf(sa.getStatus());
        else if (begin < sa.getSubSectionHeaderBegin()
            && end < sa.getSubSectionHeaderEnd())
          return "1";
      } else
        return "1";
    }
    return "-1";
View Full Code Here

      // evidence in US or V+IRA

      checkExamItr = indexes.getAnnotationIndex(SubSection.type)
          .iterator();
      while (checkExamItr.hasNext()) {
        SubSection ssId = (SubSection) checkExamItr.next();
        // US_LOWER_SOLO (ultrasound_lower_extremity_one_side_only),
        // CT_EXAM_SOLO (CAT_Scan_one_side_only)
        if (ssId.getParentSectionId().compareTo(
            ultrasound_lower_extremity_one_side_only) == 0
            || ssId.getParentSectionId().compareTo(
                "CAT_Scan_one_side_only") == 0)
          haveLowerSoloExamType = true;
        if (ssId.getParentSectionId().indexOf("V_IRAD") >= 0
            || ssId.getParentSectionId().compareTo("V&IRAD") == 0)
          haveVRADExamType = true;
        // US_EXAM (ultrasound),
        if (ssId.getParentSectionId().compareTo(ultrasound) == 0)
          haveUSExamType = true;
        // LOWER_EXT (lower_extremity),

        if (ssId.getParentSectionId().compareTo(lower_extremity) == 0)
          haveLowerExtExamType = true;
        // US_LOWER_EXT (ultrasound_lower_extremity),

        if (ssId.getParentSectionId().compareTo(
            ultrasound_lower_extremity) == 0)
          haveCombinedExamType = true;
        // US_LOWER_SOLO (ultrasound_lower_extremity_one_side_only),

        if (ssId.getParentSectionId().compareTo(
            ultrasound_lower_extremity_one_side_only) == 0)
          haveUSSoloExamType = true;
        // CT_EXAM (CAT_Scan),

        if (ssId.getParentSectionId().indexOf(CAT_Scan) > 0
            || ssId.getParentSectionId().compareTo(CAT_Scan) == 0)
          CTTypeExam = true;
      }
      boolean negCount = false;
      boolean probableCase = false;
      boolean globalProbable = false;
View Full Code Here

            .getStartOffset()) {
          correctOrder = true;
        }
      }

      SubSection subsectionAnnotation = new SubSection(jcas,
          subsectionThis.getStartOffset(),
          subsectionThis.getEndOffset());
      // Always set the beginning of the subsection at the next position
      // of the subsectionAnnotation
      subsectionAnnotation.setSubSectionBodyBegin(subsectionAnnotation
          .getEnd() + 1);

      boolean foundEnd = false;
      Set segmentSet = new HashSet();
      Iterator<?> segmentItr = indexes.getAnnotationIndex(Segment.type)
          .iterator();
      while (segmentItr.hasNext()) {
        segmentSet.add(segmentItr.next());
      }
      Iterator<?> segItr = segmentSet.iterator();
      // While there are segments
      while (segItr.hasNext()) {

        Segment segmentAnnotation = (Segment) segItr.next();
        if (segmentAnnotation.getBegin() <= subsectionThis
            .getStartOffset()
            && segmentAnnotation.getEnd() >= subsectionThis
                .getStartOffset()) {
          // Look at each sentence within the current segment
          Iterator<?> sentenceItr = FSUtil
              .getAnnotationsInSpanIterator(jcas, Sentence.type,
                  segmentAnnotation.getBegin(),
                  segmentAnnotation.getEnd());
          Sentence sentenceAnnotation = null;
          // while there are still sentences and current subsection
          // end isn't found
          while (sentenceItr.hasNext() && !foundEnd) {
            sentenceAnnotation = (Sentence) sentenceItr.next();
            if (!foundEnd && (subsectionNext != null)) {
              // correct order?
              if (subsectionNext.getStartOffset() > subsectionThis
                  .getStartOffset()) {

                // If the starting offset of the next subsection
                // is
                // greater than or equal to the end of the
                // current sentence
                // (and the end of this sentence is greater than
                // the end of
                // the current subsectionAnnotation) and the
                // beginning of the
                // current sentence is not equal to the current
                // subsection end.
                if (subsectionNext.getStartOffset() >= sentenceAnnotation
                    .getEnd()
                    && (sentenceAnnotation.getEnd() > subsectionAnnotation
                        .getEnd())
                    && (sentenceAnnotation.getBegin() != subsectionThis
                        .getStartOffset())) {
                  int newLineCount = 0;
                  Iterator<?> baseItr = FSUtil
                      .getAnnotationsInSpanIterator(
                          jcas,
                          org.apache.ctakes.typesystem.type.syntax.BaseToken.type,
                          sentenceAnnotation.getEnd(),
                          subsectionNext
                              .getStartOffset() - 1);
                  while (baseItr.hasNext()) {
                    org.apache.ctakes.typesystem.type.syntax.BaseToken checkToken = (org.apache.ctakes.typesystem.type.syntax.BaseToken) baseItr
                        .next();
                    if ((checkToken instanceof NewlineToken)
                        || (checkToken instanceof SymbolToken))
                      newLineCount++;

                  } // After taking in account the symbols and
                    // new line characters see
                    // if the ending of this sentence is
                    // adjacent to the next subsection
                    // then we found section end
                  if ((sentenceAnnotation.getEnd() + 1 + newLineCount) == subsectionNext
                      .getStartOffset()
                      || sentenceAnnotation.getEnd()
                          + newLineCount == subsectionNext
                          .getStartOffset()) {

                    foundEnd = true;
                    // set the end of the current subsection
                    // to sentence end and status
                    subsectionAnnotation
                        .setSubSectionBodyEnd(sentenceAnnotation
                            .getEnd());
                    subsectionAnnotation
                        .setStatus(subsectionThis
                            .getStatus());
                    // test new window code
                    subsectionAnnotation
                        .setSubSectionHeaderBegin(subsectionAnnotation
                            .getBegin());
                    subsectionAnnotation
                        .setSubSectionHeaderEnd(subsectionAnnotation
                            .getEnd());
                    subsectionAnnotation
                        .setEnd(subsectionAnnotation
                            .getSubSectionBodyEnd());
                    subsectionAnnotation
                        .setParentSectionId(segmentAnnotation
                            .getId());
                  }
                  // The next subsection end (or the next
                  // subsection plus one) is equal to the
                  // current
                  // sentence end then we found section end

                } else if (subsectionNext.getEndOffset() == sentenceAnnotation
                    .getEnd()
                    || subsectionNext.getEndOffset() < sentenceAnnotation
                        .getEnd()) {
                  foundEnd = true;
                  subsectionAnnotation
                      .setSubSectionBodyEnd(subsectionNext
                          .getStartOffset());
                  subsectionAnnotation
                      .setStatus(subsectionThis
                          .getStatus());
                  // test new window code
                  subsectionAnnotation
                      .setSubSectionHeaderBegin(subsectionAnnotation
                          .getBegin());
                  subsectionAnnotation
                      .setSubSectionHeaderEnd(subsectionAnnotation
                          .getEnd());
                  subsectionAnnotation
                      .setEnd(subsectionAnnotation
                          .getSubSectionBodyEnd());
                  subsectionAnnotation
                      .setParentSectionId(segmentAnnotation
                          .getId());
                }
                // if the current sentence ends at or before the
                // start of the current subsection
                // and the current sentence ends after the next
                // subsection ends (incorrect order?)
              } else if (subsectionThis.getStartOffset() <= sentenceAnnotation
                  .getEnd()
                  && (sentenceAnnotation.getEnd() > subsectionNext
                      .getEndOffset()))
                if ((sentenceAnnotation.getEnd() + 1) == subsectionThis
                    .getStartOffset()
                    || sentenceAnnotation.getEnd() == subsectionThis
                        .getStartOffset()) {
                  foundEnd = true;
                  subsectionAnnotation
                      .setSubSectionBodyEnd(sentenceAnnotation
                          .getEnd());
                  subsectionAnnotation
                      .setStatus(subsectionThis
                          .getStatus());
                  // test new window code
                  subsectionAnnotation
                      .setSubSectionHeaderBegin(subsectionAnnotation
                          .getBegin());
                  subsectionAnnotation
                      .setSubSectionHeaderEnd(subsectionAnnotation
                          .getEnd());
                  subsectionAnnotation
                      .setEnd(subsectionAnnotation
                          .getSubSectionBodyEnd());
                  subsectionAnnotation
                      .setParentSectionId(segmentAnnotation
                          .getId());
                }
              // No next subsection then
              // if there is a current subsection and end hasn't
              // been found and the subsection begin
              // is before the beginning of the current sentence,
              // but at or after the section beginning
              // and before the section ending then found end
            } else if ((subsectionThis != null)
                && (!foundEnd)
                && (subsectionThis.getStartOffset() < sentenceAnnotation
                    .getBegin())
                && (subsectionThis.getStartOffset() >= segmentAnnotation
                    .getBegin())
                && subsectionThis.getStartOffset() <= segmentAnnotation
                    .getEnd()) {
              foundEnd = true;
              subsectionAnnotation
                  .setSubSectionBodyEnd(sentenceAnnotation
                      .getEnd());
              subsectionAnnotation.setStatus(subsectionThis
                  .getStatus());
              // test new window code
              subsectionAnnotation
                  .setSubSectionHeaderBegin(subsectionAnnotation
                      .getBegin());
              subsectionAnnotation
                  .setSubSectionHeaderEnd(subsectionAnnotation
                      .getEnd());
              subsectionAnnotation.setEnd(subsectionAnnotation
                  .getSubSectionBodyEnd());
              subsectionAnnotation
                  .setParentSectionId(segmentAnnotation
                      .getId());
              // No next subsection then
              // if there is a current subsection and end hasn't
              // been found and
              // the end of the subsection heading is equal to the
              // end of the sentence (weird case)
            } else if ((subsectionThis != null)
                && (!foundEnd)
                && (subsectionThis.getEndOffset() == sentenceAnnotation
                    .getEnd())) {
              foundEnd = true;
              subsectionAnnotation
                  .setSubSectionBodyEnd(sentenceAnnotation
                      .getEnd());
              subsectionAnnotation.setStatus(subsectionThis
                  .getStatus());
              // test new window code
              subsectionAnnotation
                  .setSubSectionHeaderBegin(subsectionAnnotation
                      .getBegin());
              subsectionAnnotation
                  .setSubSectionHeaderEnd(subsectionAnnotation
                      .getEnd());
              subsectionAnnotation.setEnd(subsectionAnnotation
                  .getSubSectionBodyEnd());
              subsectionAnnotation
                  .setParentSectionId(segmentAnnotation
                      .getId());
            }

          }

        }
        if (foundEnd)
          subsectionAnnotation.addToIndexes();

      }

    }
    Iterator<?> segmentItrAgain = indexes.getAnnotationIndex(Segment.type)
        .iterator();
    while (segmentItrAgain.hasNext()) {
      Segment segmentScope = (Segment) segmentItrAgain.next();
      Iterator<?> subSectionItr = FSUtil.getAnnotationsInSpanIterator(
          jcas, SubSection.type, segmentScope.getBegin(),
          segmentScope.getEnd());
      while (subSectionItr.hasNext()) {
        SubSection checkSubsection = (SubSection) subSectionItr.next();
        // if the current segment is not one of the medical sections of
        // interest then only capture one sentence as the span of the
        // subsection when the sentence end
        // is greater then the subsection annotation end and only if the
        // subsection and sentence are w/in the section
        // boundaries
        if (/*
           * !iv_medicalSections.contains(segmentScope.getId()) &&
           */(segmentScope.getEnd() < checkSubsection
            .getSubSectionBodyEnd() || checkSubsection.getBegin() < segmentScope
            .getBegin())) {
          Iterator<?> sentenceSubSection = FSUtil
              .getAnnotationsInSpanIterator(jcas, Sentence.type,
                  segmentScope.getBegin(),
                  segmentScope.getEnd());
          boolean foundModifiedEnd = false;
          while (sentenceSubSection.hasNext() && !foundModifiedEnd) {
            Sentence checkSentence = (Sentence) sentenceSubSection
                .next();
            if (checkSentence.getBegin() >= checkSubsection
                .getBegin()
                && checkSentence.getEnd() >= checkSubsection
                    .getEnd()) {
              checkSubsection.setSubSectionBodyEnd(checkSentence
                  .getEnd());
              foundModifiedEnd = true;
            }
          }

        } else if (!subSectionItr.hasNext()) {
          checkSubsection
              .setSubSectionBodyEnd(segmentScope.getEnd() - 1);
          checkSubsection.setEnd(segmentScope.getEnd() - 1);
        }
      }
    }
  }
View Full Code Here

    boolean hasUSExam = false;
    boolean hasLowerExt = false;
    boolean hasSoloLowerExt = false;
    boolean hasCTExt = false;
    while (secItr.hasNext()) {
      SubSection sa = (SubSection) secItr.next();

      Iterator listExamTitleIter = examTitleWords.iterator();
      while (listExamTitleIter.hasNext()) {
        String entryExamTitle = (String) listExamTitleIter.next();
        String[] spanExamTitle = entryExamTitle.split(",");
        Integer lastOffset = new Integer(0);

        if (spanExamTitle.length >= 4)
          lastOffset = new Integer(spanExamTitle[3]);
        if ((sa.getCoveredText().indexOf(spanExamTitle[0]) >= new Integer(
            spanExamTitle[2]) && (lastOffset == 0 || sa
            .getCoveredText().indexOf(spanExamTitle[0]) < lastOffset))
            || (sa.getCoveredText().indexOf(spanExamTitle[0]) >= new Integer(
                spanExamTitle[2]) && (lastOffset == 0 || sa
                .getCoveredText().indexOf(spanExamTitle[0]) < lastOffset))) {

          if (spanExamTitle[1].equals("US_EXAM"))
            hasUSExam = true;
          if (spanExamTitle[1].equals("LOWER_EXT"))
            hasLowerExt = true;
          if (spanExamTitle[1].equals("US_LOWER_SOLO"))
            hasSoloLowerExt = true;
          else if (spanExamTitle[1].equals("CT_EXAM"))
            hasCTExt = true;

          if (hasUSExam && hasSoloLowerExt)
            sa.setParentSectionId("US_LOWER_SOLO");
          else if (hasLowerExt)
            sa.setParentSectionId("US_LOWER_EXT");
          else if (hasSoloLowerExt)
            sa.setParentSectionId("US_EXAM_SOLO");
          else
            sa.setParentSectionId(spanExamTitle[1]);
        }
      }

    }
    return hasCTExt;
View Full Code Here

TOP

Related Classes of org.apache.ctakes.padtermspotter.type.SubSection

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.