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