Package org.apache.uima.jcas

Examples of org.apache.uima.jcas.JFSIndexRepository


      throw new AnalysisEngineProcessException(e);
    }
  }

  private void createSubSections(JCas jcas) throws Exception {
    JFSIndexRepository indexes = jcas.getJFSIndexRepository();
    Iterator<?> subSectItr = indexes.getAnnotationIndex(
        org.apache.ctakes.typesystem.type.syntax.BaseToken.type).iterator();
    List<BaseToken> baseTokenList = new ArrayList<BaseToken>();
    while (subSectItr.hasNext()) {
      org.apache.ctakes.typesystem.type.syntax.BaseToken bta = (org.apache.ctakes.typesystem.type.syntax.BaseToken) subSectItr
          .next();
View Full Code Here


  }

  private boolean findSubSectionExamTitle(JCas jcas) {

    JFSIndexRepository indexes = jcas.getJFSIndexRepository();
    Iterator<?> secItr = indexes.getAnnotationIndex(SubSection.type)
        .iterator();
    boolean hasUSExam = false;
    boolean hasLowerExt = false;
    boolean hasSoloLowerExt = false;
    boolean hasCTExt = false;
View Full Code Here

  }

  public void process(JCas jcas) {
    List<Double> feature = new ArrayList<Double>();

    JFSIndexRepository indexes = jcas.getJFSIndexRepository();
    Iterator<?> wordTokenItr = indexes.getAnnotationIndex(WordToken.type)
        .iterator();
    List<String> unigrams = new ArrayList<String>();
    List bigrams = new ArrayList();

    while (wordTokenItr.hasNext()) {
View Full Code Here

    int[] foundTerms = new int[]{0,0,0,0,0};
    //get a list of PADTerm annotations
    try
    {
      JCas jcas = cas.getJCas();
      JFSIndexRepository indexes = jcas.getJFSIndexRepository();
     
/**********************************************************************
* NOTES: 1) Currently we are not using documentId for the webService.*
*        2) process document Id - there must be only one of these.   *
* ********************************************************************/
//      Iterator annotItr = indexes.getAnnotationIndex(DocumentId.type).iterator();
//      while(annotItr.hasNext())
//      {
//        DocumentId dia = (DocumentId)annotItr.next();
//        String sDocId = dia.getCoveredText();
//        data.append(sDocId);
//      }     
     
      //process all PADTerms
      Iterator annotItr = indexes.getAnnotationIndex(PADTerm.type).iterator();
     
      while(annotItr.hasNext())
      {
        PADTerm hft = (PADTerm)annotItr.next();
       
View Full Code Here

      ResourceProcessException {
    int count = 0;

    try {
      JCas jcas = cas.getJCas();
      JFSIndexRepository indexes;
      Iterator<?> annotItr;
      Iterator<?> checkExamItr;

      boolean haveUSSoloExamType = false;
      boolean haveUSExamType = false;
      boolean haveLowerExtExamType = false;
      boolean haveCombinedExamType = false;
      boolean haveLowerSoloExamType = false;
      boolean haveVRADExamType = false;

      boolean locTermsOnly = false;
      boolean noStenosis = true;
      boolean noVein = true;
      boolean noStent = true;
      boolean CTTypeExam = false;
      indexes = jcas.getJFSIndexRepository();
      boolean negatedCase = true;
      int locOnlyCount = 0;
      int termOnlyCount = 0;
      int probableCount = 0;
      int veinCount = 0;
      // Not needed for production use - add documentId that was collected
      // in the CAS initializer
      // if (isWindows()) {
       FSIterator<TOP> documentIDIterator = indexes.getAllIndexedFS(DocumentID.type);
      if (documentIDIterator.hasNext()) {
        DocumentID did = (DocumentID) documentIDIterator.next();
        casConsumerOffSetData.append(did.getDocumentID());

      }
      // }

      // add clinic number, etc for local run
      // if (isWindows())
      addPatientMetaData(jcas);

      annotItr = indexes.getAnnotationIndex(PADHit.type).iterator();
      casConsumerOffSetData.append(COLLECTION_SEPARATOR
          + COUNT_PLACE_HOLDER + COLLECTION_SEPARATOR);

      // Need subsection for special case where Ultrasound exams are being
      // implemented:
      // Case : UNK: if no relevant documents OR negation of positive
      // 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;
      int balanceCount = 0;
      while (annotItr.hasNext()) {
        count++;
        negatedCase = false;
        // probableCase = false;
        if (count >= 1) {
          casConsumerOffSetData.append("(");
          casConsumerOutData.append(COLLECTION_SEPARATOR);
        }

        // add segment from term or location
        PADHit uaHit = (PADHit) annotItr.next();
        if (uaHit.getUaTerm() != null)
          casConsumerOutData.append(((PADTerm) uaHit.getUaTerm())
              .getSegmentID());
        else if (uaHit.getUaLocation() != null)
          casConsumerOutData.append(((PADLocation) uaHit
              .getUaLocation()).getSegmentID());

        // add location and term data
        PADLocation ual = uaHit.getUaLocation();
        PADTerm uat = uaHit.getUaTerm();

        if (ual != null) {
          casConsumerOutData.append(COLLECTION_SEPARATOR
              + ual.getCoveredText());
          casConsumerOffSetData.append(ual.getBegin() + "-"
              + ual.getEnd() + ":");
          if (ual.getPolarity() == -1
              && uat == null
              || (ual.getPolarity() == -1 && uat != null
                  && uat.getTypeID() != disorderStenosis && ual
                  .getPolarity() == -1)) {
            negatedCase = true;
          } else if (ual.getIsStandAlone() != 1
              && ual.getPolarity() != -1
              && ual.getUncertainty() == disorderPatent) {
            probableCase = true;
            probableCount++;
          } else
            probableCase = false;
        } else {
          casConsumerOutData.append(COLLECTION_SEPARATOR + " ");
          casConsumerOffSetData.append("-1:");
          if (uat.getTypeID() == disorderStenosis
              && uat.getPolarity() != -1)
            noStenosis = false;
          if (uat != null && uat.getPolarity() == -1
              && uat.getTypeID() != disorderStenosis
              && uat.getTypeID() != anatomicalSiteExclusion)
            negatedCase = true;
          else if (uat != null
              && ((uat.getIsStandAlone() != 1 || uat.getTypeID() == disorderPatent) && uat
                  .getPolarity() != -1)) {
            probableCase = true;
            probableCount++;
          } else
            probableCase = false;
        }

        if (uat != null) {
          casConsumerOutData.append(COLLECTION_SEPARATOR
              + uat.getCoveredText());
          casConsumerOffSetData.append(uat.getBegin() + "-"
              + uat.getEnd() + ")");
          if (uat.getTypeID() == disorderStenosis
              && uat.getPolarity() != -1)
            noStenosis = false;
          if (uat.getPolarity() == -1
              && uat.getTypeID() != disorderStenosis
              && uat.getUncertainty() != disorderPatent
              && uat.getTypeID() != anatomicalSiteExclusion
              && uat.getIsStandAlone() != 1)

            negatedCase = true;
          else if (uat.getUncertainty() == disorderPatent
              && uat.getIsStandAlone() != 1) {
            probableCase = true;
            probableCount++;
          } else if (!negatedCase)
            probableCase = false;
        } else {
          casConsumerOutData.append(COLLECTION_SEPARATOR + " ");
          casConsumerOffSetData.append("-1)");
          if (ual != null && ual.getPolarity() == -1
              && ual.getUncertainty() != disorderPatent)
            negatedCase = true;
          else if (ual.getIsStandAlone() != 1
              && ual.getPolarity() != -1
              && ual.getUncertainty() == disorderPatent) {
            probableCase = true;
            probableCount++;
          }

          else
            probableCase = false;
        }

        if (probableCase)
          globalProbable = true;
        if ((negatedCase || probableCase)) {
          count--;
          negCount = true;
          if (uat != null && !probableCase
              && uat.getTypeID() != disorderStenosis
              && uat.getTypeID() != disorderPatent) {
            if (ual == null || (ual != null)
                && ual.getTypeID() != disorderPatent
                && ual.getPolarity() == -1)
              balanceCount--;

          }
        } else
          balanceCount++;

      }
      annotItr = indexes.getAnnotationIndex(PADLocation.type).iterator();
      while (annotItr.hasNext()) {
        PADLocation location = (PADLocation) annotItr.next();
        Iterator<?> annotHitItr = indexes.getAnnotationIndex(
            PADHit.type).iterator();
        boolean skip = false;
        if (location.getCoveredText().indexOf("vein") != -1) {
          noVein = false;
          veinCount++;
        }
        while (annotHitItr.hasNext() && !skip) {
          PADHit uaHit = ((PADHit) annotHitItr.next());
          if (uaHit.getUaLocation() != null
              && location.getBegin() == uaHit.getUaLocation()
                  .getBegin())
            skip = true;

        }
        if (!skip) {
          if (location.getPolarity() == -1) {
            locTermsOnly = true;
          }

          if (location.getPolarity() != -1) {

            locOnlyCount++;
            casConsumerOffSetData.append("(");

            casConsumerOffSetData.append("-1:");
            casConsumerOffSetData.append(location.getBegin() + "-"
                + location.getEnd() + ")");
            casConsumerOutData.append(COLLECTION_SEPARATOR);
            casConsumerOutData.append(location.getSegmentID());
            casConsumerOutData.append(COLLECTION_SEPARATOR
                + "**NO TERM**");
            casConsumerOutData.append(COLLECTION_SEPARATOR
                + location.getCoveredText());

          } else if (location.getPolarity() != -1
              && location.getTypeID() != disorderStenosis
              && location.getTypeID() != anatomicalSiteExclusion
              && location.getUncertainty() == disorderPatent)
            locOnlyCount--;
        }
      }
      annotItr = indexes.getAnnotationIndex(PADTerm.type).iterator();
      while (annotItr.hasNext()) {
        PADTerm term = (PADTerm) annotItr.next();
        Iterator<?> annotHitItr = indexes.getAnnotationIndex(
            PADHit.type).iterator();
        boolean skip = false;
        while (annotHitItr.hasNext() && !skip) {
          PADHit uaHit = ((PADHit) annotHitItr.next());
          if (uaHit.getUaTerm() != null
View Full Code Here

    */
   @Override
   public Iterator<LookupToken> getLookupTokenIterator( final JCas jcas ) throws AnnotatorInitializationException {
      final List<LookupToken> ltList = new ArrayList<LookupToken>();

      final JFSIndexRepository indexes = jcas.getJFSIndexRepository();
      final AnnotationIndex<Annotation> annotationIndex = indexes.getAnnotationIndex( BaseToken.type );
      for ( Annotation annotation : annotationIndex ) {
         if ( !(annotation instanceof BaseToken) ) {
            iv_logger.warn( getClass().getName() + " getLookupTokenIterator(..) Annotation is not a BaseToken" );
            continue;
         }
View Full Code Here

    * {@inheritDoc}
    */
   @Override
   public Iterator<Annotation> getLookupWindowIterator( final JCas jcas ) throws AnnotatorInitializationException {
      try {
         final JFSIndexRepository indexes = jcas.getJFSIndexRepository();
         final String objClassName = iv_props.getProperty( WINDOW_ANNOT_PRP_KEY );
         int windowType;
         try {
            windowType = JCasUtil.getType( objClassName );
         } catch ( IllegalArgumentException iaE ) {
            // thrown by JCasUtil.getType()
            throw new AnnotatorInitializationException( iaE );
         }
         return indexes.getAnnotationIndex( windowType ).iterator();
      } catch ( Exception e ) {
         // TODO specify exceptions, get rid of the catch for "Exception"
         throw new AnnotatorInitializationException( e );
      }
   }
View Full Code Here

      if ( iv_annotTypeArr == null ) {
         return Collections.emptyMap();
      }
      final List<LookupAnnotation> list = new ArrayList<LookupAnnotation>();
      // algorithm depends on a window for permutations
      final JFSIndexRepository indexes = jcas.getJFSIndexRepository();
      for ( int annotationType : iv_annotTypeArr ) {
         final Iterator<Annotation> itr = indexes.getAnnotationIndex( annotationType ).iterator();
         list.addAll( constrainToWindow( windowBegin, windowEnd, itr ) );
      }
      final Map<String, List<LookupAnnotation>> m = new HashMap<String, List<LookupAnnotation>>( 1 );
      m.put( FirstTokenPermutationImpl.CTX_KEY_WINDOW_ANNOTATIONS, list );
      return m;
View Full Code Here

    String text = jcas.getDocumentText();

    try {
      if (useSegments) {
        JFSIndexRepository indexes = jcas.getJFSIndexRepository();
        Iterator segmentItr = indexes.getAnnotationIndex(Segment.type)
            .iterator();
        while (segmentItr.hasNext()) {
          Segment segmentAnnotation = (Segment) segmentItr.next();
          String segmentID = segmentAnnotation.getId();
View Full Code Here

   * A utility method that annotates a given range.
   */
  protected void annotateRange(JCas jcas, String text, int rangeBegin,
      int rangeEnd)
      throws AnalysisEngineProcessException {
    JFSIndexRepository indexes = jcas.getJFSIndexRepository();
    Iterator wordItr = indexes.getAnnotationIndex(WordToken.type)
        .iterator();
    while (wordItr.hasNext()) {
      WordToken wordAnnotation = (WordToken) wordItr.next();
      if (wordAnnotation.getBegin() >= rangeBegin
          && wordAnnotation.getEnd() <= rangeEnd) {
View Full Code Here

TOP

Related Classes of org.apache.uima.jcas.JFSIndexRepository

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.