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

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


//    }
//    Annotation sentenceAnnotation = filteredIterator.next();
//    Sentence sentence = (Sentence)sentenceAnnotation;
   
    logger.finest("finding current or previous sentence for character offset " + characterOffset);
    Sentence sentence = findPreviousOrCurrentSentence(characterOffset);
    if (sentence == null)
    {
      logger.info("current or previous sentence IS NULL!");
    } else
    {
      logger.finest("current or previous sentence -- id: " + sentence.getAddress() +
          "; begin: " + sentence.getBegin() +
          "; end: " + sentence.getEnd());
    }
   
    int lineNumber = sentence.getSentenceNumber() + 1;
   
   
    FSIterator<Annotation> tokensInSentenceIterator =
        jcas.getAnnotationIndex(baseTokenTypeId).subiterator(sentence);
   
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

 
  @Override
  public List<Feature> extract(JCas jcas, Annotation focusAnnotation)
      throws CleartkExtractorException {
    List<Feature> feats = new ArrayList<Feature>();
    Sentence sent = null;
   
    List<Sentence> sents = JCasUtil.selectCovering(jcas, Sentence.class, focusAnnotation.getBegin(), focusAnnotation.getEnd());
    if(sents != null && sents.size() > 0){
      sent = sents.get(0);
    }else{
View Full Code Here

      {
        logger.info("no covering sentences found!!! continuing with next entity/event...");
        continue;
      }
      logger.info(String.format("covering sentence count: %d", coveringSentences.size()));
      Sentence firstCoveringSentence = coveringSentences.iterator().next();
     
      logger.info(String.format(
          "first covering sentence: [%d-%d] \"%s\" (%s)",
          firstCoveringSentence.getBegin(), firstCoveringSentence.getEnd(),
          firstCoveringSentence.getCoveredText(),
          firstCoveringSentence.getClass().getName()));
     
      List<Feature> cuePhraseFeatures =
          //cuePhraseInSentenceExtractor.extract(jcas, firstCoveringSentence);
          cuePhraseInWindowExtractor.extractWithin(jcas, current, firstCoveringSentence);
          //cuePhraseInWindowNamingExtractor.extract(jcas, current);
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

    JFSIndexRepository indexes = jcas.getJFSIndexRepository();

    Iterator<?> sentItr = indexes.getAnnotationIndex(Sentence.type)
        .iterator();
    Sentence prevSent = null;
    Sentence currSent = null;

    Map<Integer, Sentence> sentences = getSentencesOrderById(sentItr);

    // find the first Sentence in the specified range
    for (int i = 0; i < sentences.size(); i++) {
      prevSent = currSent;
      currSent = (Sentence) sentences.get(new Integer(i));

      if (currSent == null)
        iv_logger.error("Wow! some sentence is null");

      if (prevSent == null)
        continue; // got to have 2 sentences
// Added a check for the currSent being null which should not be happening, but apparently is for some reason 10/7/2011
      if (prevSent.getCoveredText().endsWith(":") && currSent != null) {
        int newEnd = -1;
        if ((currSent.getSentenceNumber() - 1) == prevSent
            .getSentenceNumber()) {
          // System.out.println("Found adjecent sentence: " +
          // prevSent.getSentenceNumber() + " is next to " +
          // currSent.getSentenceNumber());
          String textSent2 = currSent.getCoveredText().toLowerCase();
          Iterator<String> itWordsInPattern = wordsInPattern
              .iterator();
          while (itWordsInPattern.hasNext()) {
            String word = (String) itWordsInPattern.next();
            // System.out.println("Checking for word: " + word);
            if (textSent2.startsWith(word)) {
              // System.out.println("Sentence begins with word: "
              // + word);
              newEnd = currSent.getEnd();
              // System.out.println("Old Sentence ["+text.substring(prevSent.getBegin(),
              // prevSent.getEnd())+"]");
              prevSent.setEnd(newEnd);
              // System.out.println("New Sentence ["+text.substring(prevSent.getBegin(),
              // prevSent.getEnd())+"]");
              currSent.removeFromIndexes();
            }
          }
        }
      }
    }
View Full Code Here

    for (String feat : FeatureIndex) {
      vfeat.put(feat, false);
    }
   
    // find the sentence that entityMention is in
    Sentence sEntity = null;
    Collection<Sentence> sentences = JCasUtil.select(jCas, Sentence.class);
    for (Sentence s : sentences) {
      if ( s.getBegin()<=arg.getBegin() && s.getEnd()>=arg.getEnd()) {
        sEntity = s;
        break;
View Full Code Here

  }

  private Map<Integer, Sentence> getSentencesOrderById(Iterator<?> sentItr) {
    Map<Integer, Sentence> sentences = new HashMap<Integer, Sentence>();
    while (sentItr.hasNext()) {
      Sentence sa = (Sentence) sentItr.next();
      int snum = sa.getSentenceNumber();

      sentences.put((new Integer(snum)), sa);
    }

    return sentences;
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.