You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Georg Fette <ge...@uni-wuerzburg.de> on 2013/05/08 14:17:05 UTC
CasCopier and derived types of DocumentAnnotations
Hello,
I have a type system in which I have created a type which inherits from
DocumentAnnotation. As DocumentAnnotation is not inheritanceFinal I
thought that this is allowed. I have now a CAS in which I have several
annotations of that derived type. In the method copyFSInner of CasCopier
the proper target feature structure to copy instances of my type the
first DocumentAnnotation in the index of documentAnnotation of the
target CAS. Is DocumentAnnotation to be thought a singelton in a CAS ?
Why isn't it prevented in the framework to derive from it or to create
further instances of that type and add it to the CAS ?
If this is done the CasCopier can not be properly used.
Greetings
Georg
--
---------------------------------------------------------------------
Dipl.-Inf. Georg Fette Raum: B009
Universität Würzburg Tel.: +49-(0)931-31-85516
Am Hubland Fax.: +49-(0)931-31-86732
97074 Würzburg mail: georg.fette@uni-wuerzburg.de
---------------------------------------------------------------------
Re: CasCopier and derived types of DocumentAnnotations
Posted by Richard Eckart de Castilho <ri...@gmail.com>.
Hi,
in DKPro Core, we solve this by being careful ;) Our DocumentMetaData inherits from DocumentAnnotation
Mainly we create our own DKPro DocumentMetaData explicitly in the CAS *before* calling setDocumentText or setDocumentLanguage (which implicitly creates the UIMA DocumentAnnotation). Also, we added special methods to the DKPro DocumentMetaData that do not allow more than one instance in the CAS:
DocumentMetaData meta = DocumentMetaData.create(jcas);
DocumentMetaData.get(jcas);
The create() method also takes care of copying over any data from an already existing DocumentAnnotation, deleting that and creating our DocumentMetaData annotation instead.
For more examples see our test cases [1].
-- Richard
[1] http://code.google.com/p/dkpro-core-asl/source/browse/de.tudarmstadt.ukp.dkpro.core-asl/trunk/de.tudarmstadt.ukp.dkpro.core.api.metadata/src/test/java/de/tudarmstadt/ukp/dkpro/core/api/metadata/type/DocumentMetaDataTest.java?r=450
Am 08.05.2013 um 14:17 schrieb Georg Fette <ge...@uni-wuerzburg.de>:
> Hello,
> I have a type system in which I have created a type which inherits from DocumentAnnotation. As DocumentAnnotation is not inheritanceFinal I thought that this is allowed. I have now a CAS in which I have several annotations of that derived type. In the method copyFSInner of CasCopier the proper target feature structure to copy instances of my type the first DocumentAnnotation in the index of documentAnnotation of the target CAS. Is DocumentAnnotation to be thought a singelton in a CAS ? Why isn't it prevented in the framework to derive from it or to create further instances of that type and add it to the CAS ?
> If this is done the CasCopier can not be properly used.
> Greetings
> Georg
>
> --
> ---------------------------------------------------------------------
> Dipl.-Inf. Georg Fette Raum: B009
> Universität Würzburg Tel.: +49-(0)931-31-85516
> Am Hubland Fax.: +49-(0)931-31-86732
> 97074 Würzburg mail: georg.fette@uni-wuerzburg.de
> ---------------------------------------------------------------------
>
Re: CasCopier and derived types of DocumentAnnotations
Posted by Marshall Schor <ms...@schor.com>.
On 5/8/2013 4:37 PM, Richard Eckart de Castilho wrote:
> The idea that one must remove a stock-UIMA jar and replace it with another was something I always thought a bit… well… ugly.
Yes, I agree. It's an opportunity for a better approach :-).
>
> That link also doesn't say how to add features to it. Probably by defining the type in a XML. It seems a bit odd that section 5.5.3 (Impact of Type Merging on Composability of Annotators) pledges against type merging when 5.5.4 (Adding Features to DocumentAnnotation) says to use exactly that.
True. 5.5.4 therefore says how to make things work when you do this (remove the
stock-UIMA jar for DocumentAnnotation, and replace it with yours, if you are
intending to use the JCas with it).
-Marshall
Re: CasCopier and derived types of DocumentAnnotations
Posted by Richard Eckart de Castilho <ri...@gmail.com>.
The idea that one must remove a stock-UIMA jar and replace it with another was something I always thought a bit… well… ugly.
That link also doesn't say how to add features to it. Probably by defining the type in a XML. It seems a bit odd that section 5.5.3 (Impact of Type Merging on Composability of Annotators) pledges against type merging when 5.5.4 (Adding Features to DocumentAnnotation) says to use exactly that.
-- Richard
Am 08.05.2013 um 21:06 schrieb Marshall Schor <ms...@schor.com>:
> Hi,
>
> This is intended to be a singleton. But it is not "featureFinal" - so you can
> define this exact type in your type system and have any additional features you
> need added to it (without making a subtype).
>
> See this section of the reference documentation:
> http://uima.apache.org/d/uimaj-2.4.0/references.html#ugr.ref.jcas.documentannotation_issues
>
> It is probably a good idea to add to the framework something that prevents users
> from creating subtypes or multiple instances of it. Patches welcome!
>
> -Marshall
>
>
> On 5/8/2013 8:17 AM, Georg Fette wrote:
>> Hello,
>> I have a type system in which I have created a type which inherits from
>> DocumentAnnotation. As DocumentAnnotation is not inheritanceFinal I thought
>> that this is allowed. I have now a CAS in which I have several annotations of
>> that derived type. In the method copyFSInner of CasCopier the proper target
>> feature structure to copy instances of my type the first DocumentAnnotation in
>> the index of documentAnnotation of the target CAS. Is DocumentAnnotation to be
>> thought a singelton in a CAS ? Why isn't it prevented in the framework to
>> derive from it or to create further instances of that type and add it to the
>> CAS ?
>> If this is done the CasCopier can not be properly used.
>> Greetings
>> Georg
Re: CasCopier and derived types of DocumentAnnotations
Posted by Marshall Schor <ms...@schor.com>.
Hi,
This is intended to be a singleton. But it is not "featureFinal" - so you can
define this exact type in your type system and have any additional features you
need added to it (without making a subtype).
See this section of the reference documentation:
http://uima.apache.org/d/uimaj-2.4.0/references.html#ugr.ref.jcas.documentannotation_issues
It is probably a good idea to add to the framework something that prevents users
from creating subtypes or multiple instances of it. Patches welcome!
-Marshall
On 5/8/2013 8:17 AM, Georg Fette wrote:
> Hello,
> I have a type system in which I have created a type which inherits from
> DocumentAnnotation. As DocumentAnnotation is not inheritanceFinal I thought
> that this is allowed. I have now a CAS in which I have several annotations of
> that derived type. In the method copyFSInner of CasCopier the proper target
> feature structure to copy instances of my type the first DocumentAnnotation in
> the index of documentAnnotation of the target CAS. Is DocumentAnnotation to be
> thought a singelton in a CAS ? Why isn't it prevented in the framework to
> derive from it or to create further instances of that type and add it to the
> CAS ?
> If this is done the CasCopier can not be properly used.
> Greetings
> Georg
>