Package org.apache.ctakes.typesystem.type.textspan

Examples of org.apache.ctakes.typesystem.type.textspan.Sentence


    if (!filteredIterator.hasNext())
    {
      throw new RuntimeException("Surrounding sentence annotation not found!!");
    }
    Annotation sentenceAnnotation = filteredIterator.next();
    Sentence sentence = (Sentence)sentenceAnnotation;
    int lineNumber = sentence.getSentenceNumber() + 1;
   
   
    FSIterator<Annotation> tokensInSentenceIterator =
        jcas.getAnnotationIndex(baseTokenTypeId).subiterator(sentence);
   
View Full Code Here


//        modifier.removeFromIndexes();
//      }
     
      for (Sentence oldSystemSentence : JCasUtil.select(jCas, Sentence.class))
      {
        Sentence newGoldSentence = new Sentence(goldView, oldSystemSentence.getBegin(), oldSystemSentence.getEnd());
       
        newGoldSentence.addToIndexes();
      }

      for (BaseToken oldSystemToken : JCasUtil.select(jCas, BaseToken.class))
      {
        BaseToken newGoldToken = null; //new BaseToken(goldView, oldSystemEventMention.getBegin(), oldSystemEventMention.getEnd());
View Full Code Here

    ArrayList<ArrayList<String>> arrayOfLines = new ArrayList<ArrayList<String>>();
   
    //ArrayList<ApiConcept> apiConceptList = new ArrayList<ApiConcept>();
    for (Annotation annotation : sentenceAnnotationIndex)
    {
      Sentence sentence = (Sentence)annotation;
      int sentenceBegin = sentence.getBegin();
      int sentenceEnd = sentence.getEnd();
     
      AnnotationIndex<Annotation> tokenAnnotationIndex = jcas.getAnnotationIndex(BaseToken.type);
      FSIterator<Annotation> tokensInThisSentenceIterator = tokenAnnotationIndex.subiterator(sentence);
      ArrayList<String> arrayOfTokens = new ArrayList<String>();
      //for (Annotation baseTokenAnnotationUntyped : tokenAnnotationIndex)
View Full Code Here

    if (!filteredIterator.hasNext())
    {
      throw new RuntimeException("Surrounding sentence annotation not found!!");
    }
    Annotation sentenceAnnotation = filteredIterator.next();
    Sentence sentence = (Sentence)sentenceAnnotation;
    int lineNumber = sentence.getSentenceNumber() + 1;
   
   
    FSIterator<Annotation> tokensInSentenceIterator =
        jcas.getAnnotationIndex(baseTokenTypeId).subiterator(sentence);
   
View Full Code Here

    {
      return null;
      //throw new RuntimeException("Surrounding sentence annotation not found!!");
    }
    Annotation sentenceAnnotation = filteredIterator.next();
    Sentence sentence = (Sentence)sentenceAnnotation;
    int lineNumber = sentence.getSentenceNumber() + 1;
   
   
    FSIterator<Annotation> tokensInSentenceIterator =
        jcas.getAnnotationIndex(baseTokenTypeId).subiterator(sentence);
   
View Full Code Here

    Iterator iter = indexes.getAnnotationIndex(Sentence.type).iterator();
    int[] span = new int[2];

    while (iter.hasNext())
    {
      Sentence sa = (Sentence) iter.next();
      if (begin >= sa.getBegin() && end <= sa.getEnd())
      {
        span[0] = sa.getBegin();
        span[1] = sa.getEnd();
        // System.out.println("In setSentenceSpanContainingGivenSpan: begin="+span[0]+"|"+"end="+span[1]);
        break;
      }
    }
View Full Code Here

        //---check sentence-level classification
    if (iv_logger.isInfoEnabled())
     if(finalClassification!=Const.CLASS_UNKNOWN) {
          Iterator senIter = jcas.getJFSIndexRepository().getAnnotationIndex(Sentence.type).iterator();   
          while(senIter.hasNext()) {
            Sentence sen = (Sentence) senIter.next();
            iv_logger.info("|"+sen.getCoveredText() + "|" + finalClassification + "|" + negCnt);
          }
        }
        //---
     
        // add final classification as a new NominalAttributeValue object
View Full Code Here

//        modifier.removeFromIndexes();
//      }
     
      for (Sentence oldSystemSentence : JCasUtil.select(jCas, Sentence.class))
      {
        Sentence newGoldSentence = new Sentence(goldView, oldSystemSentence.getBegin(), oldSystemSentence.getEnd());
       
        newGoldSentence.addToIndexes();
      }

      for (BaseToken oldSystemToken : JCasUtil.select(jCas, BaseToken.class))
      {
        BaseToken newGoldToken = null; //new BaseToken(goldView, oldSystemEventMention.getBegin(), oldSystemEventMention.getEnd());
View Full Code Here

    }

    Iterator<?> sentItr = jcas.getJFSIndexRepository().getAnnotationIndex(
        Sentence.type).iterator();
    while (sentItr.hasNext()) {
      Sentence sentAnn = (Sentence) sentItr.next();
      /**
       * This is not to use the specified section.
       * 2-23-2009
       * The sentence adjuster has a separate means to check for skipped segments, so
       * this needs to be tested here as well.
       * 9-8-2011
       */
      // ---
//      if (sectionsToIgnore.contains(sentAnn.getSegmentId())) {
//        // System.out.println("---"+sentAnn.getSegmentId()+"|"+sentAnn.getCoveredText());
//        continue;
//      }
      Iterator<?> segItr = jcas.getJFSIndexRepository().getAnnotationIndex(Segment.type).iterator();
      Boolean skip = false;
      while (segItr.hasNext() && !skip) {
        Segment segment = (Segment) segItr.next();
        if (segment.getBegin() <= sentAnn.getBegin() && segment.getEnd() >= sentAnn.getEnd()
            && sectionsToIgnore.contains(segment.getId()))
          skip = true;

      }
      // ---
      if (!skip) {
        ClassifiableEntry entry = new ClassifiableEntry();
        entry.iv_recordID = recordID;
        entry.iv_begin = sentAnn.getBegin();
        entry.iv_end = sentAnn.getEnd();
        entry.iv_text = sentAnn.getCoveredText();
        entryList.add(entry);
      }
    }

    // collect segment annotations
View Full Code Here

  private static String formatError(JCas jcas, IdentifiedAnnotation mention){
    List<Sentence> context = JCasUtil.selectCovering(jcas, Sentence.class, mention.getBegin(), mention.getEnd());
    StringBuffer buff = new StringBuffer();
    if(context.size() > 0){
      Sentence sent = context.get(0);
      buff.append(sent.getCoveredText());
      long offset = mention.getBegin() - sent.getBegin();
      if (offset>=Integer.MAX_VALUE || offset<=Integer.MIN_VALUE) { offset=0; } // for spanless annots
      buff.insert((int)offset, "***");
      offset += (mention.getEnd()-mention.getBegin() + 3);
      buff.insert((int)offset, "***");
    }
View Full Code Here

TOP

Related Classes of org.apache.ctakes.typesystem.type.textspan.Sentence

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.