Java Code Examples for org.apache.uima.cas.impl.TypeSystemImpl#addType()
The following examples show how to use
org.apache.uima.cas.impl.TypeSystemImpl#addType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IteratorTestSorted.java From uima-uimaj with Apache License 2.0 | 6 votes |
public void setUp() { CASImpl casMgr = (CASImpl) CASFactory.createCAS(); TypeSystemImpl tsi = (TypeSystemImpl) casMgr.getTypeSystemMgr(); TypeImpl level_1_type = tsi.addType("org.apache.uima.cas.test.Level_1", tsi.annotType); tsi.addFeature("id", level_1_type, tsi.floatType); TypeImpl level_2_type = tsi.addType("org.apache.uima.cas.test.Level_2", level_1_type); TypeImpl level_3_type = tsi.addType("org.apache.uima.cas.test.Level_3", level_2_type); TypeImpl level_4_type = tsi.addType("org.apache.uima.cas.test.Level_4", level_3_type); TypeImpl level_5_type = tsi.addType("org.apache.uima.cas.test.Level_5", level_4_type); TypeImpl level_6_type = tsi.addType("org.apache.uima.cas.test.Level_6", level_5_type); casMgr.commitTypeSystem(); try { FSIndexRepositoryMgr irm = casMgr.getIndexRepositoryMgr(); casMgr.initCASIndexes(); irm.commit(); jcas = casMgr.getCurrentView().getJCas(); } catch (CASException e) { e.printStackTrace(); fail(); } }
Example 2
Source File: IndexRepositoryMergingTest.java From uima-uimaj with Apache License 2.0 | 5 votes |
protected void setUp() throws Exception { cas = (CASImpl) CASFactory.createCAS(); TypeSystemImpl ts = this.typeSystem = cas.getTypeSystemImpl(); annotSubtype = ts.addType("annotSubtype", ts.annotType); ts.addFeature("x", annotSubtype, ts.intType); cas.commitTypeSystem(); // also creates the initial indexrepository // handle type system reuse ts = this.typeSystem = cas.getTypeSystemImpl(); annotSubtype = ts.getType("annotSubtype"); cas.initCASIndexes(); // requires committed type system ir = (FSIndexRepositoryImpl) this.cas.getIndexRepositoryMgr(); FSIndexComparator comp = ir.createComparator(); Type annotation = ts.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); LinearTypeOrderBuilder tob = ir.createTypeSortOrder(); try { // tob.add(new String[] { CAS.TYPE_NAME_ANNOTATION, "annotSubtype", }); // is equal to annotationIndex tob.add(new String[] { "annotSubtype", CAS.TYPE_NAME_ANNOTATION }); // is !equal AnnotationIndex comp.addKey(tob.getOrder(), FSIndexComparator.STANDARD_COMPARE); } catch (CASException e) { TestCase.assertTrue(false); } ir.createIndex(comp, "Annot Index"); // should not be the same as the built-in one due to different type order ir.createIndex(comp, "Annot Index2"); // should not be the same as the built-in one due to different type order FSIndexComparatorImpl comp2 = ((FSIndexComparatorImpl)comp).copy(); comp2.setType(annotSubtype); ir.createIndex(comp2, "Annot Index Subtype"); // should not be the same as the built-in one due to different type order ir.commit(); }