You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Aaron Kaplan <Aa...@xrce.xerox.com> on 2008/04/01 09:08:11 UTC

Re: Copying feature structures between views

Hi Eddie.

Eddie Epstein wrote:

> For a class that just copies from one view to another, you should be 
> able to easily avoid the use of low-level methods.

Great, but how? I tried using the clone() method of the feature 
structure I wanted to copy, but that creates a feature structure that's 
associated with the original view, and I can't see how to modify it to 
be associated with the new one.  Say I'm copying from view1 to view2. 
If call setBegin() and setEnd() on the cloned FeatureStructure, and then 
call addToIndexes() with no arguments, that adds it to the index of 
view1, which is not what I want.  If I call addToIndexes(view2), I get: 
org.apache.uima.cas.CASRuntimeException: Error - the Annotation "Token 
..." is over view "view1" and cannot be added to indexes associated with 
the different view "view2".

> Note that one of the main features of this method, supporting deep 
> copies with shared FS (FS that are referenced multiple times) may not
> be needed in your case. An FS in the CAS can be referenced from any 
> view.

Agreed.  If CasCopier had worked I would have lived with its behavior, 
but in fact it would be preferable to share non-Annotation 
FeatureStructures between views rather than copying them from one to the 
other.

-Aaron


Re: Copying feature structures between views

Posted by Eddie Epstein <ea...@gmail.com>.
On Tue, Apr 1, 2008 at 3:33 AM, Aaron Kaplan <Aa...@xrce.xerox.com>
wrote:

> OK, I figured it out, with help from an archived mailing list message
> from Matthew Cammpbell.  A FeatureStructure's sofa is just a feature
> like any other, and can be set with setFeatureValue().  The reason I
> missed this the first time around is that there's no convenience method
> setSofa(), as there is for other features.
>


Right, this feature is automatically set during Annotation creation. We have
done more work with the casCopier that makes things easier, but haven't had
a chance to formalize them. Your scenario could inspire more convenience
methods too.

Eddie

Re: Copying feature structures between views

Posted by Aaron Kaplan <Aa...@xrce.xerox.com>.
OK, I figured it out, with help from an archived mailing list message 
from Matthew Cammpbell.  A FeatureStructure's sofa is just a feature 
like any other, and can be set with setFeatureValue().  The reason I 
missed this the first time around is that there's no convenience method 
setSofa(), as there is for other features.

-Aaron

Aaron Kaplan wrote:
> Hi Eddie.
> 
> Eddie Epstein wrote:
> 
>> For a class that just copies from one view to another, you should be 
>> able to easily avoid the use of low-level methods.
> 
> Great, but how? I tried using the clone() method of the feature 
> structure I wanted to copy, but that creates a feature structure that's 
> associated with the original view, and I can't see how to modify it to 
> be associated with the new one.  Say I'm copying from view1 to view2. If 
> call setBegin() and setEnd() on the cloned FeatureStructure, and then 
> call addToIndexes() with no arguments, that adds it to the index of 
> view1, which is not what I want.  If I call addToIndexes(view2), I get: 
> org.apache.uima.cas.CASRuntimeException: Error - the Annotation "Token 
> ..." is over view "view1" and cannot be added to indexes associated with 
> the different view "view2".
> 
>> Note that one of the main features of this method, supporting deep 
>> copies with shared FS (FS that are referenced multiple times) may not
>> be needed in your case. An FS in the CAS can be referenced from any view.
> 
> Agreed.  If CasCopier had worked I would have lived with its behavior, 
> but in fact it would be preferable to share non-Annotation 
> FeatureStructures between views rather than copying them from one to the 
> other.
> 
> -Aaron
>