Package org.apache.uima.cas.text

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


  public void testGetTypeSystem() {
    assertTrue(this.cas.getTypeSystem() != null);
  }
 
  public void testGetAnnotationIndex() {
    AnnotationIndex index = this.cas.getAnnotationIndex();
    assertNotNull(index);
    assertTrue(index.iterator() != null);
    boolean caughtException = false;
    try {
      this.cas.getAnnotationIndex(this.cas.getTypeSystem().getType(CAS.TYPE_NAME_TOP));
    } catch (CASRuntimeException e) {
      caughtException = true;
View Full Code Here


    logger.info(" process(JCas)");
        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);
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<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);
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

    */
   @Override
   public void process( final JCas jcas ) throws AnalysisEngineProcessException {
      _logger.info( "Starting processing" );
      final JFSIndexRepository indexes = jcas.getJFSIndexRepository();
      final AnnotationIndex annotationIndex = indexes.getAnnotationIndex( _lookupWindowType );
      if ( annotationIndex == null ) {  // I don't trust AnnotationIndex.size(), so don't check
         return;
      }
      final Map<RareWordDictionary,Collection<SpannedRareWordTerm>> dictionaryTermsMap
            = new HashMap<RareWordDictionary, Collection<SpannedRareWordTerm>>();
      final Iterator windowIterator = annotationIndex.iterator();
      try {
         while ( windowIterator.hasNext() ) {
            final Annotation window = (Annotation) windowIterator.next();
            if ( isWindowOk( window ) ) {
               processWindow( jcas, window, dictionaryTermsMap );
View Full Code Here

      try {
        jcas = aCAS.getJCas();
      } catch (CASException e) {
        throw new AnalysisEngineProcessException(e);
      }
      AnnotationIndex aIndx = jcas.getAnnotationIndex(SourceDocumentInformation.type);
      FSIterator aIter = aIndx.iterator();
      if (!aIter.isValid()) {
        String msg = name + " didn't find a SourceDocumentInformation annotation";
        System.out.println(msg);
        throw new AnalysisEngineProcessException(new Exception(msg));
      }
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

    ArrayList<Annotation> tokenList = new ArrayList<Annotation>();

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

    AnnotationIndex sentenceIndex = workingView.getAnnotationIndex(getType(workingView, this.theSentenceTypeName));
    AnnotationIndex tokenIndex = workingView.getAnnotationIndex(getType(workingView, this.theTokenTypeName));
    // iterate over Sentences
    FSIterator sentenceIterator = sentenceIndex.iterator();

    while (sentenceIterator.hasNext()) {
      Annotation sentence = (Annotation) 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

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.