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

Reply via email to