Package org.apache.uima.cas.text

Examples of org.apache.uima.cas.text.AnnotationIndex


  }

  @Override
  public void process(JCas aJCas) {
    AnnotationIndex sentenceIdx = aJCas
        .getAnnotationIndex(Sentence.typeIndexID);
    AnnotationIndex neIdx = aJCas
        .getAnnotationIndex(IdentifiedAnnotation.typeIndexID);
    negateAnnotations(aJCas, sentenceIdx, neIdx,
        new NamedEntityTargetAnnoFilter());
    if (targetTypeName != null) {
      try {
View Full Code Here


      // logger.setupDocument (getJCas ());

      FSIndex dbIndex = tcas.getAnnotationIndex(spanFeatureStructureType);
      FSIterator spanIterator = dbIndex.iterator();

      AnnotationIndex tokenIndex = (AnnotationIndex) tcas.getAnnotationIndex(tokenType);

      while (spanIterator.hasNext()) {
        ArrayList<AnnotationFS> tokens = new ArrayList<AnnotationFS>(2048);

        Annotation spanAnnotation = (Annotation) spanIterator.next();

        FSIterator tokenIter = tokenIndex.subiterator(spanAnnotation);

        // System.err.println ("Tokens:");

        // get all tokens for the specified block
        while (tokenIter.hasNext()) {
View Full Code Here

  public void process(JCas aJCas) throws AnalysisEngineProcessException {

    ArrayList<TokenAnnotation> tokenList = new ArrayList<TokenAnnotation>();
    ArrayList<String> wordList = new ArrayList<String>();

    AnnotationIndex sentenceIndex = aJCas.getAnnotationIndex(SentenceAnnotation.type);
    AnnotationIndex tokenIndex = aJCas.getAnnotationIndex(TokenAnnotation.type);

    // iterate over Sentences
    FSIterator sentenceIterator = sentenceIndex.iterator();

    while (sentenceIterator.hasNext()) {
      SentenceAnnotation sentence = (SentenceAnnotation) sentenceIterator.next();

      tokenList.clear();
      wordList.clear();

      FSIterator tokenIterator = tokenIndex.subiterator(sentence);
      while (tokenIterator.hasNext()) {
        TokenAnnotation token = (TokenAnnotation) tokenIterator.next();

        tokenList.add(token);
        wordList.add(token.getCoveredText());
View Full Code Here

    logger.info("process(JCas)");

    List<BaseToken> tokens = new ArrayList<BaseToken>();
    List<String> words = new ArrayList<String>();

    AnnotationIndex baseTokenIndex = jCas
        .getAnnotationIndex(BaseToken.type);

    FSIterator sentences = jCas.getAnnotationIndex(Sentence.type)
        .iterator();

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

      tokens.clear();
      words.clear();

      FSIterator tokenIterator = baseTokenIndex.subiterator(sentence);
      while (tokenIterator.hasNext()) {
        BaseToken token = (BaseToken) tokenIterator.next();
        tokens.add(token);
        words.add(token.getCoveredText());
      }
View Full Code Here

     
        iv_logger.info("process(JCas)");

      JFSIndexRepository indexes = jcas.getJFSIndexRepository();
      Iterator<?> sentItr = indexes.getAnnotationIndex(Sentence.type).iterator();
      AnnotationIndex baseTokenIndex = jcas.getJFSIndexRepository().getAnnotationIndex(
          org.apache.ctakes.typesystem.type.syntax.BaseToken.type);
     
      while (sentItr.hasNext()) {
        Sentence sentAnnot = (Sentence) sentItr.next();
        FSIterator btaItr = baseTokenIndex.subiterator(sentAnnot);

        // adapt JCas objects into objects expected by the Finite state
        // machines
        List<BaseToken> baseTokenList = new ArrayList<BaseToken>();
        while (btaItr.hasNext()) {
View Full Code Here

//            out = new FileOutputStream(outputFile);
//            XCASSerializer.serialize(view.getCas(), out, true); // true -> formats the output
            outputFile.createNewFile();
            BufferedWriter bw = new BufferedWriter(new FileWriter(outputFile));

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

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


                ConllDependencyNode node = null;
                FSIterator nodeIterator = nodeIndex.subiterator(sentence);
                while (nodeIterator.hasNext()) {
//                    int pID = (node==null)? 0 : node.getID();
                    node = (ConllDependencyNode) nodeIterator.next();
                   
                    if (node.getId()!=0 ) { // && node.getID() !=pID) {
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;
          }
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);
          }
View Full Code Here

    logger.info(" process(JCas)");

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

    AnnotationIndex baseTokenIndex = jCas.getAnnotationIndex(BaseToken.type);
    FSIterator sentences = jCas.getAnnotationIndex(Sentence.type).iterator();

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

      tokens.clear();

      FSIterator tokenIterator = baseTokenIndex.subiterator(sentence);
      while (tokenIterator.hasNext()) {
        BaseToken token = (BaseToken) tokenIterator.next();
        tokens.add(token);
      }
View Full Code Here

    return tags;
  }

  private List<String> getCurrentTagList(JCas cas) {
    List<String> tagList = new ArrayList<String>();
    AnnotationIndex tokenIndex = cas.getAnnotationIndex(TokenAnnotation.type);
    FSIterator tokIt = tokenIndex.iterator();
    TokenAnnotation token = null;
    for (tokIt.moveToFirst(); tokIt.isValid(); tokIt.moveToNext()) {
      token = (TokenAnnotation) tokIt.get();
      tagList.add(token.getPosTag());
    }
View Full Code Here

TOP

Related Classes of org.apache.uima.cas.text.AnnotationIndex

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.