Examples of FSIndex


Examples of org.apache.uima.cas.FSIndex

    cas1.setDocumentText("This is a test document in the initial view");
    AnnotationFS anAnnot1 = cas1.createAnnotation(cas1.getAnnotationType(), 0, 4);
    cas1.getIndexRepository().addFS(anAnnot1);
    AnnotationFS anAnnot2 = cas1.createAnnotation(cas1.getAnnotationType(), 5, 10);
    cas1.getIndexRepository().addFS(anAnnot2);
    FSIndex tIndex = cas1.getAnnotationIndex();
    assertTrue(tIndex.size() == 3); //doc annot plus  annots
   
    //serialize complete 
    XmiSerializationSharedData sharedData = new XmiSerializationSharedData();
    String xml = this.serialize(cas1, sharedData);
    int maxOutgoingXmiId = sharedData.getMaxXmiId();
    //deserialize into cas2
    XmiSerializationSharedData sharedData2 = new XmiSerializationSharedData();     
    //XmiCasDeserializer.deserialize(new StringBufferInputStream(xml), cas2, true, sharedData2);
    this.deserialize(xml, cas2, sharedData2, true, -1);
    CasComparer.assertEquals(cas1, cas2);
   
    //create Marker, add/modify fs and serialize in delta xmi format.
    Marker marker = cas2.createMarker();
    FSIndex cas2tIndex = cas2.getAnnotationIndex();
   
    //create an annotation and add to index
    AnnotationFS cas2newAnnot = cas2.createAnnotation(cas2.getAnnotationType(), 6, 8);
    cas2.getIndexRepository().addFS(cas2newAnnot);
    assertTrue(cas2tIndex.size() == 4); // prev annots and this new one
   
    //modify an existing annotation
    Iterator<FeatureStructure> tIndexIter = cas2tIndex.iterator();
    AnnotationFS docAnnot = (AnnotationFS) tIndexIter.next(); //doc annot
    //delete from index
    AnnotationFS delAnnot = (AnnotationFS) tIndexIter.next(); //annot
    cas2.getIndexRepository().removeFS(delAnnot);
    assertTrue(cas2.getAnnotationIndex().size() == 3);
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.