Hi Richard. Many thanks! You explanation really makes things clear, and also answers my question.
I still wonder whether some automatic mechanism can be developed to automatically generate TypeDescription and TypeSystemDescription directly from a Java class (under some conditions). This can shorten the learning curve of UIMA and remove the need for automatically-generated code, as well as tracking XML files in the classpath. (Such benefits are actually part of the primary goals of UimaFIT. Isn't it?) Though, such a development, even if possible, would not be trivial. 2016-09-09 17:31 GMT+03:00 Richard Eckart de Castilho <r...@apache.org>: > On 09.09.2016, at 13:39, Asher Stern <aste...@gmail.com> wrote: > > > > Hi Armin. > > Thanks for your quick answer! > > > > While the workaround is indeed helpful, I am still curios why is there no > > regular mechanism to define new types and create new descriptors > > programmatically, much like all other UIMA components? > > Sure you can define types programmatically... it's just that for the > case of types, defining them through XML is actually more convenient. > Mind that the type-system is implementation independent! You can think > of it as of an DTD or XSD. > > If you want to programmatically create a type, you can do this: > > TypeSystemDescription tsd = new TypeSystemDescription_impl(); > TypeDescription tokenTypeDesc = tsd.addType("Token", "", > CAS.TYPE_NAME_ANNOTATION); > tokenTypeDesc.addFeature("length", "", CAS.TYPE_NAME_INTEGER); > > CAS cas = CasCreationUtils.createCas(tsd, null, null); > cas.setDocumentText("This is a test."); > > Check out [1] slides 20 following. > > Cheers, > > -- Richard > > [1] https://github.com/dkpro/dkpro-tutorials/blob/master/ > GSCL2013/tags/latest/slides/GSCL2013UIMATutorialUKP.pdf