Examples of CASMgr


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

    try {
      ResultSpecification_impl rs = new ResultSpecification_impl();
      rs.addCapabilities(capabilities);

      // create Type System
      CASMgr casMgr = CASFactory.createCAS();
      TypeSystemMgr tsMgr = casMgr.getTypeSystemMgr();
      Type fakeType = tsMgr.addType("FakeType", tsMgr.getTopType());
      Type anotherType = tsMgr.addType("AnotherType", tsMgr.getTopType());
      tsMgr.addFeature("FakeFeature", fakeType, tsMgr.getTopType());
      tsMgr.addFeature("FakeFeature2", fakeType, tsMgr.getTopType());
      tsMgr.addFeature("AnotherFeature", anotherType, tsMgr.getTopType());
View Full Code Here

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

  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

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

      in.close();
      byteStream.close();
      System.out.println("Got " + bytes.length + " bytes.");

      // deserialize CAS
      CASMgr casMgr = CASFactory.createCAS();
      CASCompleteSerializer serializer = (CASCompleteSerializer) SerializationUtils
              .deserialize(bytes);
      Serialization.deserializeCASComplete(serializer, casMgr);

      // get 2nd applet parameter - right-to-left text orientation
      boolean rightToLeft = false;
      String rightToLeftParam = getParameter("RightToLeftTextOrientation");
      if (rightToLeftParam != null && rightToLeftParam.equalsIgnoreCase("true")) {
        rightToLeft = true;
      }

      // create viewer component and add to this applet
      mViewer = new CasAnnotationViewer();
      // NOTE: it seems to be important to add the viewer to the frame
      // before calling setCAS. If we do it the other way around
      // we seem to frequently cause the browser to hang.
      getContentPane().add(mViewer);

      mViewer.setCAS(casMgr.getCAS().getView(CAS.NAME_DEFAULT_SOFA));
      mViewer.setRightToLeftTextOrientation(rightToLeft);

      // add a listener that detects resize events
      addComponentListener(new MyComponentListener());
View Full Code Here

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

  // Initialize the first CAS.
  private CASMgr initCAS() {
    // Create a CASMgr. Ensures existence of AnnotationFS type.

    CASMgr localCas = CASFactory.createCAS(200);
    // Create a writable type system.
    TypeSystemMgr tsa = localCas.getTypeSystemMgr();
    // Add new types and features.

    addTypesForLevel(tsa, 4);

    // Commit the type system.
    ((CASImpl) localCas).commitTypeSystem();
    try {
      localCas.initCASIndexes();
    } catch (CASException e2) {
      e2.printStackTrace();
      assertTrue(false);
    }

    localCas.getIndexRepositoryMgr().commit();
    // assert(cas.getIndexRepositoryMgr().isCommitted());
    return localCas;
  }
View Full Code Here

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

  }

  // Initialize the first CAS.
  public void testInitCAS() {
    // Create a CASMgr. Ensures existence of AnnotationFS type.
    CASMgr cas1 = CASFactory.createCAS();
    // Create a writable type system.
    TypeSystemMgr tsa = cas1.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);
    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);
    // Commit the type system.
    ((CASImpl) cas1).commitTypeSystem();
    // Create the Base indexes.
    try {
      cas1.initCASIndexes();
    } catch (CASException e2) {
      e2.printStackTrace();
      assertTrue(false);
    }

    FSIndexRepositoryMgr irm = cas1.getIndexRepositoryMgr();

    // Check that appropriate exception is thrown on unknown types.
    LinearTypeOrderBuilder order = irm.createTypeSortOrder();
    boolean excCaught = false;
    try {
View Full Code Here

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

      in.close();
      byteStream.close();
      System.out.println("Got " + bytes.length + " bytes.");

      // deserialize CAS
      CASMgr casMgr = CASFactory.createCAS();
      CASCompleteSerializer serializer = (CASCompleteSerializer) SerializationUtils
              .deserialize(bytes);
      Serialization.deserializeCASComplete(serializer, casMgr);

      // create tree viewer component and add to this applet
      mTreeViewer = new CasTreeViewer(casMgr.getCAS().getView(CAS.NAME_DEFAULT_SOFA));
      getContentPane().add(mTreeViewer);

      // add a listener that detects resize events
      addComponentListener(new MyComponentListener());
View Full Code Here

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

  private Feature doubleArrayFeature;

  protected void setUp() throws Exception {
    viewer = new CasAnnotationViewer();

    CASMgr casMgr = CASFactory.createCAS();
    CasCreationUtils.setupTypeSystem(casMgr, (TypeSystemDescription) null);
    // Create a writable type system.
    TypeSystemMgr tsa = casMgr.getTypeSystemMgr();
    // Add new types and features.
    annotationType = tsa.getType(CAS.TYPE_NAME_ANNOTATION);
    assertTrue(annotationType != null);

    // new primitive types
    exampleType = tsa.addType("test.primitives.Example", annotationType);

    floatFeature = tsa.addFeature("floatFeature", exampleType, tsa.getType(CAS.TYPE_NAME_FLOAT));
    stringFeature = tsa.addFeature("stringFeature", exampleType, tsa.getType(CAS.TYPE_NAME_STRING));
    booleanFeature = tsa.addFeature("boolFeature", exampleType, tsa.getType(CAS.TYPE_NAME_BOOLEAN));
    byteFeature = tsa.addFeature("byteFeature", exampleType, tsa.getType(CAS.TYPE_NAME_BYTE));
    shortFeature = tsa.addFeature("shortFeature", exampleType, tsa.getType(CAS.TYPE_NAME_SHORT));
    longFeature = tsa.addFeature("longFeature", exampleType, tsa.getType(CAS.TYPE_NAME_LONG));
    doubleFeature = tsa.addFeature("doubleFeature", exampleType, tsa.getType(CAS.TYPE_NAME_DOUBLE));

    intArrayFeature = tsa.addFeature("intArrayFeature", exampleType, tsa
            .getType(CAS.TYPE_NAME_INTEGER_ARRAY));
    floatArrayFeature = tsa.addFeature("floatArrayFeature", exampleType, tsa
            .getType(CAS.TYPE_NAME_FLOAT_ARRAY), false);
    stringArrayFeature = tsa.addFeature("stringArrayFeature", exampleType, tsa
            .getType(CAS.TYPE_NAME_STRING_ARRAY), false);
    booleanArrayFeature = tsa.addFeature("boolArrayFeature", exampleType, tsa
            .getType(CAS.TYPE_NAME_BOOLEAN_ARRAY));
    byteArrayFeature = tsa.addFeature("byteArrayFeature", exampleType, tsa
            .getType(CAS.TYPE_NAME_BYTE_ARRAY), false);
    shortArrayFeature = tsa.addFeature("shortArrayFeature", exampleType, tsa
            .getType(CAS.TYPE_NAME_SHORT_ARRAY));
    longArrayFeature = tsa.addFeature("longArrayFeature", exampleType, tsa
            .getType(CAS.TYPE_NAME_LONG_ARRAY));
    doubleArrayFeature = tsa.addFeature("doubleArrayFeature", exampleType, tsa
            .getType(CAS.TYPE_NAME_DOUBLE_ARRAY), false);

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

    // Create the Base indexes.
    casMgr.initCASIndexes();
    FSIndexRepositoryMgr irm = casMgr.getIndexRepositoryMgr();
    // init.initIndexes(irm, casMgr.getTypeSystemMgr());
    irm.commit();

    cas = casMgr.getCAS().getView(CAS.NAME_DEFAULT_SOFA);

  }
View Full Code Here

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

      // "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

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

    // 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);
    // 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

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

  // Initialize the first CAS.
  private static CASMgr initCAS() {
    // // Create a CASMgr. Ensures existence of AnnotationFS type.
    // CASMgr tcas = CASFactory.createCAS();
    CASMgr casMgr = CASFactory.createCAS();
    try {
      CasCreationUtils.setupTypeSystem(casMgr, (TypeSystemDescription) null);
    } catch (ResourceInitializationException e) {
      e.printStackTrace();
    }
    // Create a writable type system.
    TypeSystemMgr tsa = casMgr.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);
    // Commit the type system.
    ((CASImpl) casMgr).commitTypeSystem();
    // assert(tsa.isCommitted());
    // // Create the CAS indexes.
    // tcas.initCASIndexes();
    // Create the Base indexes.
    try {
      casMgr.initCASIndexes();
    } catch (CASException e) {
      e.printStackTrace();
    }

    FSIndexRepositoryMgr irm = casMgr.getIndexRepositoryMgr();
    FSIndexComparator comp = irm.createComparator();
    Type annotation = tsa.getType(CAS.TYPE_NAME_ANNOTATION);
    comp.setType(annotation);
    comp.addKey(annotation.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_BEGIN),
            FSIndexComparator.STANDARD_COMPARE);
    comp.addKey(annotation.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_END),
            FSIndexComparator.REVERSE_STANDARD_COMPARE);
    irm.createIndex(comp, ANNOT_BAG_INDEX, FSIndex.BAG_INDEX);
    irm.createIndex(comp, ANNOT_SET_INDEX, FSIndex.SET_INDEX);

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

    // Create the default text Sofa and return CAS view
    return (CASMgr) casMgr.getCAS().getCurrentView();
  }
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.