uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Eckart de Castilho <...@apache.org>
Subject Re: General question about UimaFIT
Date Fri, 09 Sep 2016 14:31:51 GMT
On 09.09.2016, at 13:39, Asher Stern <astern7@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.


-- Richard

[1] https://github.com/dkpro/dkpro-tutorials/blob/master/GSCL2013/tags/latest/slides/GSCL2013UIMATutorialUKP.pdf
View raw message