You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Manuel Fiorelli <ma...@gmail.com> on 2008/10/18 02:45:20 UTC

[UIMA] How to get the element type from a TypeSystem Object

I need to get the element type of a feature from a TypeSystem object. I
didn't find any method in the Feature interface. However, when I have a
definition like that

<featureDescription>
<name>foo</name>
<rangeTypeName>uima.cas.FSArray</rangeType>
<elementType>uima.cas.Boolean</elementType>
</featureDescription>

then, foo.getRange().getComponentType() gives uima.cas.Boolean, as I
expected.
But, if the range type is uima.cas.FSList I know no way to get the element
type.

I tried the code

TypeSystemUtil.feature2FeatureDescription(base_foo).getElementType()

but it returns null.

Manuel Fiorelli

Re: [UIMA] How to get the element type from a TypeSystem Object

Posted by Manuel Fiorelli <ma...@gmail.com>.
I have opened the Jira issue:

https://issues.apache.org/jira/browse/UIMA-1208

Feel free to add any information through comments.

Manuel Fiorelli

Re: [UIMA] How to get the element type from a TypeSystem Object

Posted by Manuel Fiorelli <ma...@gmail.com>.
>
> However, I do agree that we should be consistent about whether the
> element type is accessable through the TypeSystem.


Thanks you for the answer.

Manuel Fiorelli

Re: [UIMA] How to get the element type from a TypeSystem Object

Posted by Adam Lally <al...@alum.rpi.edu>.
On Mon, Oct 20, 2008 at 1:19 PM, Thilo Goetz <tw...@gmx.de> wrote:
> Manuel Fiorelli wrote:
>>
>> I need to convert a data representation into a CAS. Then, I would like to
>> check the list element type to see if the data type were convertible.
>> Reading this paragraph
>>
>>
>> http://incubator.apache.org/uima/downloads/releaseDocs/2.2.2-incubating/docs/html/references/references.html#ugr.ref.xml.component_descriptor.type_system.features
>>
>> I convinced myself that elementType was applicable also to list types. May
>> be there is an error in the documentation?
>
> I'm afraid so.  Looks like this was wishful thinking on the part
> of whoever wrote that.  The code for getComponentType() looks
> like this:
>

I think that would be me who wrote that.  The element type is there
for documentation purposes, and it's used in the Ecore type system
conversion stuff, but that's it.  (Even for arrays, UIMA doesn't do
much with the element type - it's not enforced in any way.)  The
documentation does say that the element type constraint may or may not
be enforced.  We had also thought maybe it might be supported in JCAS
someday.

However, I do agree that we should be consistent about whether the
element type is accessable through the TypeSystem.

  -Adam

Re: [UIMA] How to get the element type from a TypeSystem Object

Posted by Thilo Goetz <tw...@gmx.de>.
Manuel Fiorelli wrote:
> I need to convert a data representation into a CAS. Then, I would like to
> check the list element type to see if the data type were convertible.
> Reading this paragraph
> 
> http://incubator.apache.org/uima/downloads/releaseDocs/2.2.2-incubating/docs/html/references/references.html#ugr.ref.xml.component_descriptor.type_system.features
> 
> I convinced myself that elementType was applicable also to list types. May
> be there is an error in the documentation?

I'm afraid so.  Looks like this was wishful thinking on the part
of whoever wrote that.  The code for getComponentType() looks
like this:

   public Type getComponentType() {
     if (!isArray()) {
       return null;
     }
     return this.ts.ll_getTypeForCode(this.ts.ll_getComponentType(this.code));
   }

So lists are not covered.  I don't know what happens if you
specify a component type for a list valued feature in a
descriptor, but I expect it will raise some kind of
exception.  Please open a Jira issue, we should at least
fix the documentation.  Thanks for pointing this out.

--Thilo

> 
> Manuel Fiorelli
> 

Re: [UIMA] How to get the element type from a TypeSystem Object

Posted by Manuel Fiorelli <ma...@gmail.com>.
I need to convert a data representation into a CAS. Then, I would like to
check the list element type to see if the data type were convertible.
Reading this paragraph

http://incubator.apache.org/uima/downloads/releaseDocs/2.2.2-incubating/docs/html/references/references.html#ugr.ref.xml.component_descriptor.type_system.features

I convinced myself that elementType was applicable also to list types. May
be there is an error in the documentation?

Manuel Fiorelli

Re: [UIMA] How to get the element type from a TypeSystem Object

Posted by Thilo Goetz <tw...@gmx.de>.
Manuel Fiorelli wrote:
> I need to get the element type of a feature from a TypeSystem object. I
> didn't find any method in the Feature interface. However, when I have a
> definition like that
> 
> <featureDescription>
> <name>foo</name>
> <rangeTypeName>uima.cas.FSArray</rangeType>
> <elementType>uima.cas.Boolean</elementType>
> </featureDescription>
> 
> then, foo.getRange().getComponentType() gives uima.cas.Boolean, as I
> expected.
> But, if the range type is uima.cas.FSList I know no way to get the element
> type.
> 
> I tried the code
> 
> TypeSystemUtil.feature2FeatureDescription(base_foo).getElementType()
> 
> but it returns null.
> 
> Manuel Fiorelli
> 

Lists don't work the same way as arrays.  They don't use the
elementType declaration, so you can't get at their "element
type" using getElementType().  In fact, since you can't declare
an element type, that wouldn't make much sense anyway ;-).

If you tell us what it is your trying to achieve, maybe we
can suggest a workaround.

--Thilo