Package org.apache.uima.cas

Examples of org.apache.uima.cas.FSIterator


        List<ConllDependencyNode> nodes = new ArrayList<ConllDependencyNode>();
        List<BaseToken> tokens          = new ArrayList<BaseToken>();

        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);
            while (tokenIterator.hasNext()) {
                tokens.add((BaseToken) tokenIterator.next());
            }
            //logger.info(" new sentence: ");
            FSIterator nodeIterator = nodeIndex.subiterator(sentence);
            while (nodeIterator.hasNext()) {
                ConllDependencyNode node = (ConllDependencyNode) nodeIterator.next();
                if (node.getId()!=0) {
                    nodes.add(node);
                }
                //logger.info(node.getFORM()+" ");
            }
View Full Code Here


    this.jcas = jcas;

    // index the base tokens and NEs by their offsets
    hbs = new Hashtable<Integer, BaseToken>();
    hbe = new Hashtable<Integer, BaseToken>();
    FSIterator iter = jcas.getJFSIndexRepository().getAnnotationIndex(BaseToken.type).iterator();
    while (iter.hasNext()) {
      BaseToken t = (BaseToken) iter.next();
      hbs.put(t.getBegin(), t);
      hbe.put(t.getEnd(), t);
    }
  }
View Full Code Here

      annot1.getCoveredText().contains(annot2.getCoveredText());
  }
 
  /** 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

  /** Returns the first ConllDependencyNode in the CAS w/ same begin and end as the given Annotation **/ 
  public static ConllDependencyNode getDependencyNode(JCas jCas, Annotation annot) {

    AnnotationIndex nodeIndex = jCas.getAnnotationIndex(ConllDependencyNode.type);
      FSIterator nodeIterator = nodeIndex.iterator();
      while (nodeIterator.hasNext()) {
          ConllDependencyNode node = (ConllDependencyNode) nodeIterator.next();
          if (equalCoverage(annot,node)) {
            return node;
          }
      }
      return null;
View Full Code Here

 
  /** Returns the ConllDependencyNodes in the CAS w/ subsumed begins and ends **/ 
  public static List<ConllDependencyNode> getDependencyNodes(JCas jCas, Annotation annot) {
    ArrayList<ConllDependencyNode> output = new ArrayList<ConllDependencyNode>();
    AnnotationIndex nodeIndex = jCas.getAnnotationIndex(ConllDependencyNode.type);
      FSIterator nodeIterator = nodeIndex.iterator();
      while (nodeIterator.hasNext()) {
          ConllDependencyNode node = (ConllDependencyNode) nodeIterator.next();
          if (doesSubsume(annot,node)) {
            output.add(node);
          }
      }
      return output;
View Full Code Here

        List<ConllDependencyNode> nodes = new ArrayList<ConllDependencyNode>();
        List<BaseToken> tokens          = new ArrayList<BaseToken>();

        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);
            while (tokenIterator.hasNext()) {
                tokens.add((BaseToken) tokenIterator.next());
            }

            FSIterator nodeIterator = nodeIndex.subiterator(sentence);
            while (nodeIterator.hasNext()) {
                ConllDependencyNode node = (ConllDependencyNode) nodeIterator.next();
                if (node.getId()!=0) {
                    nodes.add(node);
                }
            }
View Full Code Here

    if (docId==null) docId = "141471681_1";
    System.out.print("creating vectors for "+docId);
//    Vector<Span> goldSpans = loadGoldStandard(docId, goldSpan2id);
    int numPos = 0;

    FSIterator markIter = jcas.getAnnotationIndex(Markable.type).iterator();
    LinkedList<Annotation> lm = FSIteratorToList.convert(markIter);

//    while(markIter.hasNext()){
//      Markable m = (Markable) markIter.next();
//      String key = m.getBegin() + "-" + m.getEnd();
//      markables.put(key, m);
//    }
   
    labeler = new GoldStandardLabeler(goldStandardDir, docId, lm);

//    Vector<Span> sysSpans = loadSystemPairs(lm, docId);
    // align the spans


    FSIterator iter = null;
//    FSIterator iter = jcas.getJFSIndexRepository().getAllIndexedFS(AnaphoricityVecInstance.type);
//    int numVecs = corefNodes.size();
//    log.info(numVecs + " nodes at the start of processing...");

//    if(anaphora){
//      while(iter.hasNext()){
//        AnaphoricityVecInstance vec = (AnaphoricityVecInstance) iter.next();
//        String nodeStr = vec.getVector();
//        int label = getLabel(nodeStr);
//        if(label == 1) posAnaphInst++;
//        else if(label == 0) negAnaphInst++;
//        anaphLabels.add(label);
//        svm_node[] nodes = SvmUtils.getNodes(nodeStr);
//        anaphNodes.add(nodes);
//      }
//      return;
//    }
   
    if(printVectors){
      try {
        neOut = new PrintWriter(outputDir + "/" + CorefConsts.NE + "/vectors/" + docId + ".libsvm");
        demOut = new PrintWriter(outputDir + "/" + CorefConsts.DEM + "/vectors/" + docId + ".libsvm");
        pronOut = new PrintWriter(outputDir + "/" + CorefConsts.PRON + "/vectors/"+ docId + ".libsvm");
      } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    //    int ind = 0;
    iter = jcas.getJFSIndexRepository().getAllIndexedFS(MarkablePairSet.type);
    while(iter.hasNext()){
      //      VecInstance vec = (VecInstance) iter.next();
      MarkablePairSet pair = (MarkablePairSet) iter.next();
      Markable anaphor = pair.getAnaphor();
      String corefType = (anaphor instanceof NEMarkable ? CorefConsts.NE : (anaphor instanceof DemMarkable ? CorefConsts.DEM : CorefConsts.PRON));
      //      String nodeStr = vec.getVector();
      //      int label = getLabel(nodeStr);
      FSList pairList = pair.getAntecedentList();
View Full Code Here

  }

  // FIXME use parser output instead of LWA
  public String calcmNPHead () {
    Annotation a = m.getContent();
    FSIterator iter = jcas.getJFSIndexRepository().getAnnotationIndex(LookupWindowAnnotation.type).iterator();
    while (iter.hasNext()) {
      LookupWindowAnnotation lwa = (LookupWindowAnnotation) iter.next();
      if (lwa.getBegin()<=a.getBegin() && lwa.getEnd()==a.getEnd())
        return "yes";
    }
    return "no";
  }
View Full Code Here

// the inclusionCondition resource (use parameter?) MarkableCreator
public class AnnotationSelector {

  public static ArrayList<Annotation> selectNE (JCas jcas) {
    ArrayList<Annotation> ret = new ArrayList<Annotation>();
    FSIterator iter = jcas.getJFSIndexRepository().getAnnotationIndex(EntityMention.type).iterator();
    while (iter.hasNext()) {
      EntityMention a = (EntityMention) iter.next();
      if(a.getOntologyConceptArr() != null)
//      int tid = a.getTypeID();
//      if (tid == TypeSystemConst.NE_TYPE_ID_ANATOMICAL_SITE ||
//        tid == TypeSystemConst.NE_TYPE_ID_DISORDER ||
//        tid == TypeSystemConst.NE_TYPE_ID_PROCEDURE ||
View Full Code Here

    return ret;
  }

  public static ArrayList<BaseToken> selectBaseToken (JCas jcas) {
    ArrayList<BaseToken> ret = new ArrayList<BaseToken>();
    FSIterator iter = jcas.getJFSIndexRepository().getAnnotationIndex(BaseToken.type).iterator();
    while (iter.hasNext())
      ret.add((BaseToken)iter.next());
    java.util.Collections.sort(ret, new AnnotOffsetComparator());
    return ret;
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.cas.FSIterator

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.