You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by Spiros Meliopoulos <sm...@omilia.com> on 2017/03/17 11:12:35 UTC

Creating Annotations runtime

Hello uima world!

I am a new user of the framework and I need some help.

Let's say that I have a service that I pass to it text and it returns an
object (org.mozilla.javascript.NativeObject) with some properties and
values.

So far, I have a way for annotators to work with selected parts
(types/features) of that data by using an xml and jcasgen to create the
necessary classes (features).

In case response (NativeObject) includes a new property, I have to add in
the xml and compile the project.

Is there a way to make the whole process happen in runtime? In short, can
we avoid recompile;

thank you all in advance

Spiros G. Meliopoulos | Software Engineer  | skype: spiros.meliopoulos

Re: Creating Annotations runtime

Posted by Spiros Meliopoulos <sm...@omilia.com>.
thank you!!!!!!!!!!

Spiros G. Meliopoulos | Software Engineer  | skype: spiros.meliopoulos



On 17 March 2017 at 16:50, Marshall Schor <ms...@schor.com> wrote:

> Please read the UIMA Reference doc, chapter 4.
>
> http://uima.apache.org/d/uimaj-current/references.html#ugr.ref.cas
>
> See especially section 4.2.2, and 4.4.
>
> The non-JCas API access to create and modify Feature Structures are
> described
> starting in 4.4.2 and later sections.
>
> The APIs, which can be used for adding types and features (before the type
> system is committed), are described in the Javadocs.  There's a small
> intro to
> those in chapter 4.8.
>
> A good source of examples of the APIs being used are the test cases in the
> uimaj-core project source.
>
> For example: this test builds a type system using the APIs; that part is
> encapsulated into a class.
> https://svn.apache.org/repos/asf/uima/uimaj/trunk/uimaj-
> core/src/test/java/org/apache/uima/cas/test/AnnotationIteratorTest.java
>
> The encapsulated type system build code (run during test setup):
> https://svn.apache.org/repos/asf/uima/uimaj/trunk/uimaj-
> core/src/test/java/org/apache/uima/cas/test/CASTestSetup.java
>
> Hope this helps.
>
> -Marshall
>
> On 3/17/2017 9:01 AM, Spiros Meliopoulos wrote:
> > Hi Marshall,
> >
> > We have already think of 1st work around but it has been rejected.
> >
> > As for 2nd solution, it is exactly what we want. Can you share these
> > generic non-JCAS API though I have been lost a little bit with the
> > references and the guides? As you have realized I used jcas (uima-fit).
> >
> > thank you for your help!
> >
> > best regards
> >
> > Spiros G. Meliopoulos | Software Engineer  | skype: spiros.meliopoulos
> >
> >
> >
> > On 17 March 2017 at 14:44, Marshall Schor <ms...@schor.com> wrote:
> >
> >> Hi Spiros,
> >>
> >> There are many alternatives...
> >>
> >> UIMA chooses to normally favor performance, so it has a "compile" then
> >> "run"
> >> design, as you note.
> >>
> >> Here are some ways to work around this.
> >>
> >> 1) Design a runtime - flexible type.  The basic idea is to have this
> type
> >> keep a
> >> level of indirection to the name - value pair(s), normally associated
> with
> >> UIMA
> >> Features and their values.  For instance, you could have an array of
> >> Strings
> >> (for the names) and an associated array of values.
> >>
> >> 2) If you have a lifecycle where you can determine what the additional
> >> features
> >> needed are before you start your pipeline, you don't need to "compile"
> >> things -
> >> you can use the UIMA APIs to add those features to the type system
> before
> >> you
> >> produce your pipeline.   You might think you need to "compile" the
> >> associated
> >> JCas methods, but UIMA provides a generic non-JCas API for accessing the
> >> CAS,
> >> driven by Types and Features which can be discovered at initialization
> >> time (of
> >> the pipeline) by your annotators.
> >>
> >> Of course, then you can't use JCas access methods, but you wouldn't be
> >> using
> >> those anyways, I'm guessing for these "new" features, because at the
> time
> >> you
> >> wrote the annotator code, you were unaware of these feature's existance.
> >>
> >> Does this help at all?
> >>
> >>
> >> -Marshall
> >>
> >> On 3/17/2017 7:12 AM, Spiros Meliopoulos wrote:
> >>> Hello uima world!
> >>>
> >>> I am a new user of the framework and I need some help.
> >>>
> >>> Let's say that I have a service that I pass to it text and it returns
> an
> >>> object (org.mozilla.javascript.NativeObject) with some properties and
> >>> values.
> >>>
> >>> So far, I have a way for annotators to work with selected parts
> >>> (types/features) of that data by using an xml and jcasgen to create the
> >>> necessary classes (features).
> >>>
> >>> In case response (NativeObject) includes a new property, I have to add
> in
> >>> the xml and compile the project.
> >>>
> >>> Is there a way to make the whole process happen in runtime? In short,
> can
> >>> we avoid recompile;
> >>>
> >>> thank you all in advance
> >>>
> >>> Spiros G. Meliopoulos | Software Engineer  | skype: spiros.meliopoulos
> >>>
> >>
>
>

Re: Creating Annotations runtime

Posted by Marshall Schor <ms...@schor.com>.
Please read the UIMA Reference doc, chapter 4.

http://uima.apache.org/d/uimaj-current/references.html#ugr.ref.cas

See especially section 4.2.2, and 4.4.

The non-JCas API access to create and modify Feature Structures are described
starting in 4.4.2 and later sections.

The APIs, which can be used for adding types and features (before the type
system is committed), are described in the Javadocs.  There's a small intro to
those in chapter 4.8.

A good source of examples of the APIs being used are the test cases in the
uimaj-core project source.

For example: this test builds a type system using the APIs; that part is
encapsulated into a class.
https://svn.apache.org/repos/asf/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/AnnotationIteratorTest.java

The encapsulated type system build code (run during test setup):
https://svn.apache.org/repos/asf/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/CASTestSetup.java

Hope this helps.

-Marshall

On 3/17/2017 9:01 AM, Spiros Meliopoulos wrote:
> Hi Marshall,
>
> We have already think of 1st work around but it has been rejected.
>
> As for 2nd solution, it is exactly what we want. Can you share these
> generic non-JCAS API though I have been lost a little bit with the
> references and the guides? As you have realized I used jcas (uima-fit).
>
> thank you for your help!
>
> best regards
>
> Spiros G. Meliopoulos | Software Engineer  | skype: spiros.meliopoulos
>
>
>
> On 17 March 2017 at 14:44, Marshall Schor <ms...@schor.com> wrote:
>
>> Hi Spiros,
>>
>> There are many alternatives...
>>
>> UIMA chooses to normally favor performance, so it has a "compile" then
>> "run"
>> design, as you note.
>>
>> Here are some ways to work around this.
>>
>> 1) Design a runtime - flexible type.  The basic idea is to have this type
>> keep a
>> level of indirection to the name - value pair(s), normally associated with
>> UIMA
>> Features and their values.  For instance, you could have an array of
>> Strings
>> (for the names) and an associated array of values.
>>
>> 2) If you have a lifecycle where you can determine what the additional
>> features
>> needed are before you start your pipeline, you don't need to "compile"
>> things -
>> you can use the UIMA APIs to add those features to the type system before
>> you
>> produce your pipeline.   You might think you need to "compile" the
>> associated
>> JCas methods, but UIMA provides a generic non-JCas API for accessing the
>> CAS,
>> driven by Types and Features which can be discovered at initialization
>> time (of
>> the pipeline) by your annotators.
>>
>> Of course, then you can't use JCas access methods, but you wouldn't be
>> using
>> those anyways, I'm guessing for these "new" features, because at the time
>> you
>> wrote the annotator code, you were unaware of these feature's existance.
>>
>> Does this help at all?
>>
>>
>> -Marshall
>>
>> On 3/17/2017 7:12 AM, Spiros Meliopoulos wrote:
>>> Hello uima world!
>>>
>>> I am a new user of the framework and I need some help.
>>>
>>> Let's say that I have a service that I pass to it text and it returns an
>>> object (org.mozilla.javascript.NativeObject) with some properties and
>>> values.
>>>
>>> So far, I have a way for annotators to work with selected parts
>>> (types/features) of that data by using an xml and jcasgen to create the
>>> necessary classes (features).
>>>
>>> In case response (NativeObject) includes a new property, I have to add in
>>> the xml and compile the project.
>>>
>>> Is there a way to make the whole process happen in runtime? In short, can
>>> we avoid recompile;
>>>
>>> thank you all in advance
>>>
>>> Spiros G. Meliopoulos | Software Engineer  | skype: spiros.meliopoulos
>>>
>>


Re: Creating Annotations runtime

Posted by Spiros Meliopoulos <sm...@omilia.com>.
Hi Marshall,

We have already think of 1st work around but it has been rejected.

As for 2nd solution, it is exactly what we want. Can you share these
generic non-JCAS API though I have been lost a little bit with the
references and the guides? As you have realized I used jcas (uima-fit).

thank you for your help!

best regards

Spiros G. Meliopoulos | Software Engineer  | skype: spiros.meliopoulos



On 17 March 2017 at 14:44, Marshall Schor <ms...@schor.com> wrote:

> Hi Spiros,
>
> There are many alternatives...
>
> UIMA chooses to normally favor performance, so it has a "compile" then
> "run"
> design, as you note.
>
> Here are some ways to work around this.
>
> 1) Design a runtime - flexible type.  The basic idea is to have this type
> keep a
> level of indirection to the name - value pair(s), normally associated with
> UIMA
> Features and their values.  For instance, you could have an array of
> Strings
> (for the names) and an associated array of values.
>
> 2) If you have a lifecycle where you can determine what the additional
> features
> needed are before you start your pipeline, you don't need to "compile"
> things -
> you can use the UIMA APIs to add those features to the type system before
> you
> produce your pipeline.   You might think you need to "compile" the
> associated
> JCas methods, but UIMA provides a generic non-JCas API for accessing the
> CAS,
> driven by Types and Features which can be discovered at initialization
> time (of
> the pipeline) by your annotators.
>
> Of course, then you can't use JCas access methods, but you wouldn't be
> using
> those anyways, I'm guessing for these "new" features, because at the time
> you
> wrote the annotator code, you were unaware of these feature's existance.
>
> Does this help at all?
>
>
> -Marshall
>
> On 3/17/2017 7:12 AM, Spiros Meliopoulos wrote:
> > Hello uima world!
> >
> > I am a new user of the framework and I need some help.
> >
> > Let's say that I have a service that I pass to it text and it returns an
> > object (org.mozilla.javascript.NativeObject) with some properties and
> > values.
> >
> > So far, I have a way for annotators to work with selected parts
> > (types/features) of that data by using an xml and jcasgen to create the
> > necessary classes (features).
> >
> > In case response (NativeObject) includes a new property, I have to add in
> > the xml and compile the project.
> >
> > Is there a way to make the whole process happen in runtime? In short, can
> > we avoid recompile;
> >
> > thank you all in advance
> >
> > Spiros G. Meliopoulos | Software Engineer  | skype: spiros.meliopoulos
> >
>
>

Re: Creating Annotations runtime

Posted by Marshall Schor <ms...@schor.com>.
Hi Spiros,

There are many alternatives... 

UIMA chooses to normally favor performance, so it has a "compile" then "run"
design, as you note.

Here are some ways to work around this.

1) Design a runtime - flexible type.  The basic idea is to have this type keep a
level of indirection to the name - value pair(s), normally associated with UIMA
Features and their values.  For instance, you could have an array of Strings
(for the names) and an associated array of values.

2) If you have a lifecycle where you can determine what the additional features
needed are before you start your pipeline, you don't need to "compile" things -
you can use the UIMA APIs to add those features to the type system before you
produce your pipeline.   You might think you need to "compile" the associated
JCas methods, but UIMA provides a generic non-JCas API for accessing the CAS,
driven by Types and Features which can be discovered at initialization time (of
the pipeline) by your annotators.

Of course, then you can't use JCas access methods, but you wouldn't be using
those anyways, I'm guessing for these "new" features, because at the time you
wrote the annotator code, you were unaware of these feature's existance.

Does this help at all?


-Marshall

On 3/17/2017 7:12 AM, Spiros Meliopoulos wrote:
> Hello uima world!
>
> I am a new user of the framework and I need some help.
>
> Let's say that I have a service that I pass to it text and it returns an
> object (org.mozilla.javascript.NativeObject) with some properties and
> values.
>
> So far, I have a way for annotators to work with selected parts
> (types/features) of that data by using an xml and jcasgen to create the
> necessary classes (features).
>
> In case response (NativeObject) includes a new property, I have to add in
> the xml and compile the project.
>
> Is there a way to make the whole process happen in runtime? In short, can
> we avoid recompile;
>
> thank you all in advance
>
> Spiros G. Meliopoulos | Software Engineer  | skype: spiros.meliopoulos
>