Package org.apache.uima.cas

Examples of org.apache.uima.cas.CAS.createAnnotation()


        if (wsLine && !emptyLine) {
          AnnotationFS newWSLineFS = cas.createAnnotation(wsLineType, offsetTillNow, offsetTillNow
                  + eachLine.length());
          cas.addFsToIndexes(newWSLineFS);
        } else if (!emptyLine) {
          AnnotationFS newLineFS = cas.createAnnotation(lineType, offsetTillNow, offsetTillNow
                  + eachLine.length());
          cas.addFsToIndexes(newLineFS);

          lastWasEmpty = false;
          lastLineEnd = offsetTillNow + eachLine.length();
View Full Code Here


          lastWasEmpty = false;
          lastLineEnd = offsetTillNow + eachLine.length();
        }
        if (wsLine && !lastWasEmpty && lastLineEnd != 0) {
          AnnotationFS newParaFS = cas.createAnnotation(paragraphType, paragraphBegin, lastLineEnd);
          cas.addFsToIndexes(newParaFS);
        } else if (offsetAfterLine + nlLength == documentText.length()) {
          AnnotationFS newParaFS = cas.createAnnotation(paragraphType, paragraphBegin,
                  offsetAfterLine);
          cas.addFsToIndexes(newParaFS);
View Full Code Here

        }
        if (wsLine && !lastWasEmpty && lastLineEnd != 0) {
          AnnotationFS newParaFS = cas.createAnnotation(paragraphType, paragraphBegin, lastLineEnd);
          cas.addFsToIndexes(newParaFS);
        } else if (offsetAfterLine + nlLength == documentText.length()) {
          AnnotationFS newParaFS = cas.createAnnotation(paragraphType, paragraphBegin,
                  offsetAfterLine);
          cas.addFsToIndexes(newParaFS);
        }
        if (wsLine) {
          lastWasEmpty = true;
View Full Code Here

      assertNotNull(cas.getIndexRepository().getIndex("TestIndex"));
      assertNotNull(cas.getIndexRepository().getIndex("ReverseAnnotationIndex"));
      assertNotNull(cas.getIndexRepository().getIndex("DocumentStructureIndex"));

      // check of type priority
      AnnotationFS fs1 = cas.createAnnotation(cas.getTypeSystem().getType("Paragraph"), 0, 1);
      AnnotationFS fs2 = cas.createAnnotation(cas.getTypeSystem().getType("Sentence"), 0, 1);
      assertTrue(cas.getAnnotationIndex().compare(fs1, fs2) < 0);
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
View Full Code Here

      assertNotNull(cas.getIndexRepository().getIndex("ReverseAnnotationIndex"));
      assertNotNull(cas.getIndexRepository().getIndex("DocumentStructureIndex"));

      // check of type priority
      AnnotationFS fs1 = cas.createAnnotation(cas.getTypeSystem().getType("Paragraph"), 0, 1);
      AnnotationFS fs2 = cas.createAnnotation(cas.getTypeSystem().getType("Sentence"), 0, 1);
      assertTrue(cas.getAnnotationIndex().compare(fs1, fs2) < 0);
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

      assertTrue(heapSize <= bufSize);
     
      //create enough annotations to exceed the DEFAULT_RESET_HEAP_SIZE
      Type annotType = cas.getTypeSystem().getType(CAS.TYPE_NAME_ANNOTATION);
      for (int i = 0; i < 2000000; i++) {
        cas.createAnnotation(annotType, i, i);
      }
     
      heapSize = ((CASImpl) cas).getHeap().getHeapSize();
      bufSize = ((CASImpl)cas).getHeap().heap.length;
      //System.out.println("Heap size: " + heapSize + ", buffer size: " + bufSize);     
View Full Code Here

     
      //If instead we create the annotations in smaller chunks and reset each time,
      //the CAS buffer size shouldn't grow   
      for (int j = 0; j < 10; j++) {
        for (int i = 0; i < 200000; i++) {
          cas.createAnnotation(annotType, i, i);
        }
       
        heapSize = ((CASImpl) cas).getHeap().getHeapSize();
        bufSize = ((CASImpl)cas).getHeap().heap.length;
        //System.out.println("Heap size: " + heapSize + ", buffer size: " + bufSize);     
View Full Code Here

      String thisTok = st.nextToken();
      int engBegin = engText.indexOf(thisTok, engEnd);
      engEnd = engBegin + thisTok.length();

      // Create token annotations on English text
      AnnotationFS engAnnot = engTcas.createAnnotation(annot, engBegin, engEnd);
      engTcas.getIndexRepository().addFS(engAnnot);

      // Simple word-by-word translation
      String germWord = Translate(thisTok);
View Full Code Here

  public void run() {
    AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());

    CAS documentCAS = mDocument.getCAS();

    AnnotationFS mergedAnnotation = documentCAS.createAnnotation(annotations.getFirst().getType(),
            annotations.getFirst().getBegin(), annotations.getLast().getEnd());

    mDocument.removeFeatureStructures(annotations.toList());
    mDocument.addFeatureStructure(mergedAnnotation);
  }
View Full Code Here

            .getType("uima.tt.TestAnnotation");
      featurePath.typeInit(testAnnotType);

      Type testAnnotSubType = cas.getTypeSystem().getType(
            "uima.tt.TestAnnotSub");
      AnnotationFS fs = cas.createAnnotation(testAnnotSubType, 0, 1);
      cas.addFsToIndexes(fs);

      featurePath.getValueAsString(fs);

   }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.