uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Armin.Weg...@bka.bund.de>
Subject AW: Using OpenNLP type annotations with UIMAfit
Date Mon, 26 Jan 2015 08:24:32 GMT
Hi Aleksandar!

For full flexibility I use CAS (not JCas). It's a bit inelegant to use, but you can introduce
new types at runtime. Together with UIMAfit it is very nice in JUnit tests. And you can set
types (type names) as annotator parameters. For example, you can choose the input and output
types of an annotator at runtime. But, as Richard has already mentioned, you are responsible
for type checking yourself. Giving a wrong or non-existing type name can cause difficult to
find NullPointerExceptions. Check for null and handle exceptions carefully.


-----Urspr├╝ngliche Nachricht-----
Von: Aleksandar Dimitrov [mailto:aleks.dimitrov@gmail.com] 
Gesendet: Montag, 26. Januar 2015 00:36
An: user@uima.apache.org
Betreff: Re: Using OpenNLP type annotations with UIMAfit [Signatur ung├╝ltig]


Thanks for taking the time to answer! Your mail helped lift quite some
confusions I had.

> No, it is not generated at runtime. It is generated manually or at build-time,
> e.g. using the maven-jcasgen-plugin.

Right, I was wondering when that happened, and just thought it would be
run-time, since I never saw the familiar <typeName>.java and
<typeName>_Type.java files anywhere.

> OpenNLP aims to be configurable with regards to types. So you must have *some*
> type system that you configure OpenNLP to use, right?

Yes, the OpenNLP type system that ships with the OpenNlp source. Though I think
after our discussion, I might just switch over to my own type system (most of
which will be a verbatim copy.)

> Open it in the Eclipse
> UIMA Type-System Editor and hit the "JCasGen" button - it will generate the
> JCas classes that you can use with uimaFIT JCasUtil.

I'm not using Eclipse, but I believe that maven-jcasgen-plugin would help me

> typeSystemInit() is meant for CAS-based analysis engines, not for JCas-based annotators.

Oh, that's interesting! I was confused, because its an overridable method for

> You need the CAS-based API only if you want to configure your components at
> runtime with regards to the annotation types they should use.

So that's the way OpenNLP does it?

> If you can stick to a specific type system, use the JCas-based analysis
> engines.

I can, and I think I shall.

> The CAS-API is not type-safe. Neither is the UIMA-JCas API, but the uimaFIT JCas-API
is ;)

Rigt, so I usually dislike having to have the JCas-Gen-generated files lying
around (no real reason, except that it adds another step to the source setup
and compilation process, and I'm not using Eclipse) but I *very* much enjoy
uimaFIT's type safety in AnalysisEngines, so I think I'll bite the bullet.

> You could alternatively use an alternative OpenNLP binding for UIMA, e.g. the
> one provided by DKPro Core [1] (not an Apache project, but one I'm working on
> too).

I've been looking at and reading the DKPro code extensively. It's nice and easy
to read, and has helped me along with finding solutions to some problems
(I've been using it mostly as example code for an uimaFIT setup!)
Just this one I couldn't figure out :-) And sometimes I chose different avenues,
for example I ended up using a URLStreamHandlerFactory instead of dkpro's
ResourceUtils.resolveLocation() to load my resource files from within JARs (or
indeed any other location.)

View raw message