Package org.apache.uima.cas.admin

Examples of org.apache.uima.cas.admin.CASMgr


    // System.out.println("Size of bag index: " + bagSize);

    CASCompleteSerializer cs;
    cs = Serialization.serializeCASComplete(casMgr);
    // casMgr = CASFactory.createCAS();
    CASMgr realCasMgr = CASFactory.createCAS();
    ((CASImpl) realCasMgr).commitTypeSystem();
    Serialization.deserializeCASComplete(cs, realCasMgr);
    cas = ((CASImpl) realCasMgr).getCurrentView();
    casMgr = (CASMgr) cas;
View Full Code Here


*/
public class CASInitializer {

  public static CAS initCas(AnnotatorInitializer init) {
    // Create an initial CASMgr from the factory.
    CASMgr casMgr0 = CASFactory.createCAS();
    CASMgr casMgr = null;
    try {
      // this call does nothing: because 2nd arg is null
      CasCreationUtils.setupTypeSystem(casMgr0, (TypeSystemDescription) null);
      // Create a writable type system.
      TypeSystemMgr tsa = casMgr0.getTypeSystemMgr();
      // Next not needed, type system is already uncommitted
//      ((TypeSystemImpl) tsa).setCommitted(false);
      // do the type system tests
      init.initTypeSystem(tsa);
      // Commit the type system.
      ((CASImpl) casMgr0).commitTypeSystem();

      casMgr = CASFactory.createCAS(tsa);

      // Create the Base indexes.
      casMgr.initCASIndexes();
      // Commit the index repository.
      FSIndexRepositoryMgr irm = casMgr.getIndexRepositoryMgr();
      init.initIndexes(irm, casMgr.getTypeSystemMgr());
      irm.commit();
    } catch (ResourceInitializationException e) {
      e.printStackTrace();
    } catch (CASException e) {
      e.printStackTrace();
    }

    // Create the default text Sofa and return CAS view
    return casMgr.getCAS().getCurrentView();
  }
View Full Code Here

*/
public class CASInitializer {

  public static CAS initCas(AnnotatorInitializer init) throws CASException {
    // Create an initial CASMgr from the factory.
    CASMgr casMgr = CASFactory.createCAS();
    // Create a writable type system.
    TypeSystemMgr tsa = casMgr.getTypeSystemMgr();
    // assert(tsa != null);
    // Create a CASMgr. Ensures existence of AnnotationFS type.
    init.initTypeSystem(tsa);
    // Commit the type system.
    ((CASImpl) casMgr).commitTypeSystem();
    // assert(tsa.isCommitted());
    // Create the CAS indexes.
    casMgr.initCASIndexes();

    // tcasMgr.initCASIndexes();
    FSIndexRepositoryMgr irm = casMgr.getIndexRepositoryMgr();
    init.initIndexes(irm, casMgr.getTypeSystemMgr());
    // Commit the index repository.
    irm.commit();
    // assert(cas.getIndexRepositoryMgr().isCommitted());

    return casMgr.getCAS().getCurrentView();
  }
View Full Code Here

    // Create an initial CASMgr from the factory.
    // CASMgr cas = CASFactory.createCAS();
    // assert(tsa != null);
    // Create a CASMgr. Ensures existence of AnnotationFS type.
    // CASMgr tcas = CASFactory.createCAS();
    CASMgr aCas = CASFactory.createCAS();
    try {
      CasCreationUtils.setupTypeSystem(aCas, (TypeSystemDescription) null);
    } catch (ResourceInitializationException e) {
      e.printStackTrace();
    }
    // Create a writable type system.
    TypeSystemMgr tsa = aCas.getTypeSystemMgr();
    // Add new types and features.
    Type topType = tsa.getTopType();
    Type annotType = tsa.getType(CAS.TYPE_NAME_ANNOTATION);
    // assert(annotType != null);
    tsa.addType(SENT_TYPE, annotType);
    Type tokenType = tsa.addType(TOKEN_TYPE, annotType);
    Type tokenTypeType = tsa.addType(TOKEN_TYPE_TYPE, topType);
    tsa.addType(WORD_TYPE, tokenTypeType);
    tsa.addType(SEP_TYPE, tokenTypeType);
    tsa.addType(EOS_TYPE, tokenTypeType);
    tsa.addFeature(TOKEN_TYPE_FEAT, tokenType, tokenTypeType);
    tsa.addStringSubtype(STRING_SUBTYPE_1, STR_1_VALS);
    Type stringType = tsa.getType(CAS.TYPE_NAME_STRING);
    Type byteType = tsa.getType(CAS.TYPE_NAME_BYTE);
    Type byteArrayType = tsa.getType(CAS.TYPE_NAME_BYTE_ARRAY);
    Type shortType = tsa.getType(CAS.TYPE_NAME_SHORT);
    Type shortArrayType = tsa.getType(CAS.TYPE_NAME_SHORT_ARRAY);
    Type longType = tsa.getType(CAS.TYPE_NAME_LONG);
    Type theTypeType = tsa.addType(OSTR_TYPE, annotType);
    tsa.addFeature(OSTR_TYPE_FEAT, theTypeType, stringType);
    tsa.addFeature(OBYTE_TYPE_FEAT, theTypeType, byteType);
    tsa.addFeature(OSHORT_TYPE_FEAT, theTypeType, shortType);
    tsa.addFeature(OBYTEA_TYPE_FEAT, theTypeType, byteArrayType);
    tsa.addFeature(OSHORTA_TYPE_FEAT, theTypeType, shortArrayType);
    tsa.addFeature(OLONG_TYPE_FEAT, theTypeType, longType);
    // Commit the type system.
    ((CASImpl) aCas).commitTypeSystem();
    // assert(tsa.isCommitted());
    // // Create the CAS indexes.
    // tcas.initCASIndexes();
    // Create the Base indexes.
    try {
      aCas.initCASIndexes();
    } catch (CASException e) {
      e.printStackTrace();
    }

    // Commit the index repository.
    aCas.getIndexRepositoryMgr().commit();
    // assert(cas.getIndexRepositoryMgr().isCommitted());

    // Create the default text Sofa and return CAS view
    return (CASMgr) aCas.getCAS().getCurrentView();
  }
View Full Code Here

    super(arg0);
  }

  public void testSerialization() throws Exception {
    try {
      CASMgr cas = null;
      try {
        cas = (CASMgr) CASInitializer.initCas(new CASTestSetup());
      } catch (Exception e) {
        assertTrue(false);
      }
      ((CAS) cas).setDocumentText("Create the sofa for the inital view");
      assertTrue(((CASImpl) cas).isBackwardCompatibleCas());
      CASCompleteSerializer ser = Serialization.serializeCASComplete(cas);

      // deserialize into a new CAS with a type system that only contains the builtins
      CAS newCas = CasCreationUtils.createCas(new TypeSystemDescription_impl(), null, null);

      try {
        Serialization.deserializeCASComplete(ser, (CASImpl) newCas);
      } catch (Exception e) {
        assertTrue(false);
      }
      assertTrue(cas.getTypeSystemMgr().getType(CASTestSetup.GROUP_1) != null);
      assertTrue(((CASImpl) newCas).isBackwardCompatibleCas());
      assertEquals("Create the sofa for the inital view", newCas.getDocumentText());

      // make sure JCas can be created
      newCas.getJCas();

      // deserialize into newCas a second time (OF bug found 7/7/2006)
      try {
        Serialization.deserializeCASComplete(ser, (CASImpl) newCas);
      } catch (Exception e) {
        assertTrue(false);
      }
      assertTrue(cas.getTypeSystemMgr().getType(CASTestSetup.GROUP_1) != null);
      assertTrue(((CASImpl) newCas).isBackwardCompatibleCas());
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

      fail(e.getLocalizedMessage());
    }
  }

  private CAS createCAS() throws ResourceInitializationException, CASException {
    CASMgr casMgr0 = CASFactory.createCAS();
    CASMgr casMgr = null;
    CasCreationUtils.setupTypeSystem(casMgr0, null);

    TypeSystemMgr tsa = casMgr0.getTypeSystemMgr();

    ((CASImpl) casMgr0).commitTypeSystem();

    casMgr = CASFactory.createCAS(tsa);

    casMgr.initCASIndexes();
    FSIndexRepositoryMgr irm = casMgr.getIndexRepositoryMgr();
    irm.commit();

    return casMgr.getCAS().getCurrentView();
  }
View Full Code Here

      fail(e.getLocalizedMessage());
    }
  }

  private CAS createCAS() throws ResourceInitializationException, CASException {
    CASMgr casMgr0 = CASFactory.createCAS();
    CASMgr casMgr = null;
    CasCreationUtils.setupTypeSystem(casMgr0, null);

    TypeSystemMgr tsa = casMgr0.getTypeSystemMgr();

    ((CASImpl) casMgr0).commitTypeSystem();

    casMgr = CASFactory.createCAS(tsa);

    casMgr.initCASIndexes();
    FSIndexRepositoryMgr irm = casMgr.getIndexRepositoryMgr();
    irm.commit();

    return casMgr.getCAS().getCurrentView();
  }
View Full Code Here

  }


  private static CAS getCAS() {
    // Create an initial CASMgr from the factory.
    CASMgr casMgr0 = CASFactory.createCAS();
    CASMgr casMgr = null;
    try {
      // this call does nothing: because 2nd arg is null
      CasCreationUtils.setupTypeSystem(casMgr0, null);
      // Create a writable type system.
      TypeSystemMgr tsa = casMgr0.getTypeSystemMgr();

      // Commit the type system.
      ((CASImpl) casMgr0).commitTypeSystem();

      casMgr = CASFactory.createCAS(tsa);

      // Create the Base indexes.
      casMgr.initCASIndexes();
      // Commit the index repository.
      FSIndexRepositoryMgr irm = casMgr.getIndexRepositoryMgr();

      irm.commit();
    } catch (ResourceInitializationException e) {
      e.printStackTrace();
    } catch (CASException e) {
      e.printStackTrace();
    }

    // Create the default text Sofa and return CAS view
    return casMgr.getCAS().getCurrentView();
  }
View Full Code Here

  public void callProcess(CAS aCAS) throws ResourceServiceException {
    try {
      AFrame requestFrame = new AFrame();
      requestFrame.fset(Constants.VINCI_COMMAND, Constants.ANNOTATE);
      // serialize CAS (including type system)
      CASMgr cas = (CASMgr) aCAS;
      CASCompleteSerializer serializer = Serialization.serializeCASComplete(cas);

      requestFrame.fsetTrueBinary("BinaryCAS", SerializationUtils.serialize(serializer));

      AFrame responseFrame = (AFrame) mVinciClient.sendAndReceive(requestFrame, mTimeout);
View Full Code Here

      // "com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

      MainFrame frame = new MainFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      CASMgr casMgr = CASFactory.createCAS();
      frame.setTypeSystem(casMgr.getTypeSystemMgr());

      // frame.showAnnotFeats();

      frame.pack();
      frame.setVisible(true);
View Full Code Here

TOP

Related Classes of org.apache.uima.cas.admin.CASMgr

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.