Java Code Examples for org.apache.uima.cas.impl.TypeSystemImpl#getType()
The following examples show how to use
org.apache.uima.cas.impl.TypeSystemImpl#getType() .
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: ResultSpecification_impl.java From uima-uimaj with Apache License 2.0 | 6 votes |
private Iterable<String> subtypeNames(final String typeName) { final TypeSystemImpl ts = (TypeSystemImpl) mTypeSystem; return new Iterable<String>() { public Iterator<String> iterator() { return new Iterator<String>() { Type t = (null == ts) ? null : ts.getType(typeName); List<Type> subtypes = (null == ts) ? EMPTY_TYPE_LIST : (null == t ) ? EMPTY_TYPE_LIST : ts.getProperlySubsumedTypes(t); int i = 0; public boolean hasNext() { return i < subtypes.size(); } public String next() { return subtypes.get(i++).getName(); } public void remove() {throw new UnsupportedOperationException();} }; } }; }
Example 2
Source File: NewPrimitiveTypesTest.java From uima-uimaj with Apache License 2.0 | 6 votes |
private void reinitTypeSystem(TypeSystemImpl tsa) { annotationType = tsa.getType(CAS.TYPE_NAME_ANNOTATION); // new primitive types exampleType = tsa.refreshType(exampleType); floatFeature = tsa.refreshFeature(floatFeature); stringFeature = tsa.refreshFeature(stringFeature); booleanFeature = tsa.refreshFeature(booleanFeature); byteFeature = tsa.refreshFeature(byteFeature); shortFeature = tsa.refreshFeature(shortFeature); longFeature = tsa.refreshFeature(longFeature); doubleFeature = tsa.refreshFeature(doubleFeature); intArrayFeature = tsa.refreshFeature(intArrayFeature); floatArrayFeature = tsa.refreshFeature(floatArrayFeature); stringArrayFeature = tsa.refreshFeature(stringArrayFeature); booleanArrayFeature = tsa.refreshFeature(booleanArrayFeature); byteArrayFeature = tsa.refreshFeature(byteArrayFeature); shortArrayFeature = tsa.refreshFeature(shortArrayFeature); longArrayFeature = tsa.refreshFeature(longArrayFeature); doubleArrayFeature = tsa.refreshFeature(doubleArrayFeature); }
Example 3
Source File: UimacppEngine.java From uima-uimaj with Apache License 2.0 | 5 votes |
private static void serializeResultSpecification(ResultSpecification rs, CASImpl cas, IntVector resultSpecTypes, IntVector resultSpecFeatures) { TypeOrFeature[] tofs = rs.getResultTypesAndFeatures(); TypeSystemImpl tsImpl = cas.getTypeSystemImpl(); for (int i = 0; i < tofs.length; ++i) { if (tofs[i].isType()) { TypeImpl t = (TypeImpl) tsImpl.getType(tofs[i].getName()); resultSpecTypes.add(t.getCode()); } else { FeatureImpl f = (FeatureImpl) tsImpl.getFeatureByFullName(tofs[i].getName()); resultSpecFeatures.add(f.getCode()); } } }
Example 4
Source File: AnalysisEngineImplBase.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * @see org.apache.uima.analysis_engine.AnalysisEngine#getFeatureNamesForType(java.lang.String) */ public synchronized String[] getFeatureNamesForType(String aTypeName) { // build CAS and populate mFirstTypeSystem CASImpl cas = (CASImpl) getCasManager().getCas(this.getUimaContextAdmin().getQualifiedContextName()); TypeSystemImpl ts = cas.getTypeSystemImpl(); getCasManager().releaseCas(cas); TypeImpl t = ts.getType(aTypeName); return (t == null) ? null : t.getFeaturesAsStream().map(f -> f.getShortName()).toArray(size -> new String[size]); }
Example 5
Source File: TypeSystemReinitTest.java From uima-uimaj with Apache License 2.0 | 5 votes |
public void testReinitCASCompleteSerializerWithArrays() throws Exception { try { AnalysisEngineDescription aed = UIMAFramework.getXMLParser().parseAnalysisEngineDescription( new XMLInputSource(JUnitExtension .getFile("ExampleTae/arrayTypeSerialization.xml"))); CAS cas1 = CasCreationUtils.createCas(aed); cas1.setDocumentText("foo"); CASCompleteSerializer ser = Serialization.serializeCASComplete((CASMgr) cas1); CAS tcas2 = CasCreationUtils.createCas(new TypeSystemDescription_impl(), null, null); CASImpl cas2 = ((CASImpl) tcas2).getBaseCAS(); tcas2.setDocumentText("bar"); // reinit // This uses cas2 which only has a base type system to start, // and loads it from a complete serialization which has other new types cas2.getBinaryCasSerDes().reinit(ser); CAS tcas3 = cas2.getCurrentView(); assertTrue(tcas2 == tcas3); assertNotNull(cas1.getTypeSystem().getType("Test.ArrayType")); assertNotNull(tcas3.getTypeSystem().getType("Test.ArrayType")); TypeSystemImpl ts = (TypeSystemImpl)cas2.getTypeSystem(); Type arrayType = ts.getType("Test.ArrayType"); Feature arrayFeat = arrayType.getFeatureByBaseName("arrayFeature"); TypeImpl featRange = (TypeImpl)(arrayFeat.getRange()); assertTrue(ts.ll_isArrayType(featRange.getCode())); assertFalse(arrayFeat.isMultipleReferencesAllowed()); } catch (Exception e) { JUnitExtension.handleException(e); } }
Example 6
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(); }