// Initialize the first CAS.
private static CASMgr initCAS() throws CASException {
// // 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();
}