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

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


        AnnotationIndex nodeIndex = jCas.getAnnotationIndex(ConllDependencyNode.type);
        AnnotationIndex tokenIndex = jCas.getAnnotationIndex(BaseToken.type);
        FSIterator sentences = jCas.getAnnotationIndex(Sentence.type).iterator();

        while (sentences.hasNext()) {
            Sentence sentence = (Sentence) sentences.next();

            tokens.clear();
            nodes.clear();

            FSIterator tokenIterator = tokenIndex.subiterator(sentence);
View Full Code Here


        AnnotationIndex nodeIndex = jCas.getAnnotationIndex(ConllDependencyNode.type);
        AnnotationIndex tokenIndex = jCas.getAnnotationIndex(BaseToken.type);
        FSIterator sentences = jCas.getAnnotationIndex(Sentence.type).iterator();

        while (sentences.hasNext()) {
            Sentence sentence = (Sentence) sentences.next();
           
            tokens.clear();
            nodes.clear();

            FSIterator tokenIterator = tokenIndex.subiterator(sentence);
View Full Code Here

    // Add sentence annotations to the CAS
    int previousEnd = -1;
    for (int i = 0; i < sentenceSpans.size(); i++) {
      SentenceSpan span = sentenceSpans.get(i);
      if (span.getStart() != span.getEnd()) { // skip empty lines
        Sentence sa = new Sentence(jcas);
        sa.setBegin(span.getStart());
        sa.setEnd(span.getEnd());
        if (previousEnd <= sa.getBegin()) {
          // System.out.println("Adding Sentence Annotation for " +
          // span.toString());
          sa.setSentenceNumber(sentenceCount);
          sa.addToIndexes();
          sentenceCount++;
          previousEnd = span.getEnd();
        } else {
          logger.error("Skipping sentence from " + span.getStart()
              + " to " + span.getEnd());
View Full Code Here

 
  /** Find the sentence in which an Annotation lives **/
  public static Sentence getSentence( JCas jCas, Annotation annot ) {
    FSIterator sentences = jCas.getAnnotationIndex(Sentence.type).iterator();
    while (sentences.hasNext()) {
      Sentence sentence = (Sentence) sentences.next();
      if (doesSubsume(sentence,annot)) {
        return sentence;
      }
    }
    return null;
View Full Code Here

  }

  /** Given a CAS, find the path between two nodes in a sentence **/
  public static DependencyPath getPath( JCas jCas, ConllDependencyNode node1, ConllDependencyNode node2) {
   
    Sentence sent1 = getSentence( jCas, node1);
    Sentence sent2 = getSentence( jCas, node2);
    if (sent1.equals(sent2)) {
      return getPath( getDependencyNodes(jCas, sent1), node1, node2);
    } else {
      logger.debug("Cannot find path between nodes in different sentences. Node1: "
          + node1.getCoveredText() + "  Node2: " + node2.getCoveredText());     
View Full Code Here

    Sentence[] sent = new Sentence[window+1];
    for (int i = 0; i <= window; i++) sent[i] = null;

    for (int i = 0; i < lm.size(); i++) {
      for (int j = 1; j <= window; j++) sent[j-1] = sent[j];
      Sentence ss = (Sentence) lm.get(i);
      sent[window] = ss;
      if (ss.getBegin() <= m.getBegin() && ss.getEnd() >= m.getEnd()) {
        for (int k = window-1; k >= 0 && sent[k] != null; k--) {
          List<String> lt = contentWords(sent[k].getBegin(), sent[k].getEnd());
          for (String s : lt)
            if (contentTokens.contains(s))
              return "Y";
        }
      } else if (ss.getBegin() > m.getBegin())
        return "N";
    }
    return "N";
  }
View Full Code Here

  @Override
  public List<Feature> extract(JCas jCas, IdentifiedAnnotation arg1,
      IdentifiedAnnotation arg2) throws AnalysisEngineProcessException {
    List<Feature> feats = new ArrayList<Feature>();
   
    Sentence coveringSent = JCasUtil.selectCovering(jCas, Sentence.class, arg1.getBegin(), arg1.getEnd()).get(0);
    List<EventMention> events = JCasUtil.selectCovered(EventMention.class, coveringSent);
    List<EventMention> realEvents = new ArrayList<EventMention>();
    for(EventMention event : events){
      // filter out ctakes events
      if(event.getClass().equals(EventMention.class)){
View Full Code Here

  public List<Feature> extract(JCas view, Annotation mention)
      throws CleartkExtractorException {
    ArrayList<Feature> feats = new ArrayList<Feature>();
    List<Sentence> sents = JCasUtil.selectCovering(view, Sentence.class, mention.getBegin(), mention.getEnd());
    if(sents.size() == 0) return feats;
    Sentence sent = sents.get(0);
    List<BaseToken> tokens = JCasUtil.selectCovered(BaseToken.class, sent);
    int startIndex = -1;
    int endIndex = -1;
   
    for(int i = 0; i < tokens.size(); i++){
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

//        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

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.