[ 
https://issues.apache.org/jira/browse/UIMA-6153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16981876#comment-16981876
 ] 

Marshall Schor commented on UIMA-6153:
--------------------------------------

I can't find an approach which works.  It would need to implement the following 
kind of type inferencing in generic types:

1) if the generic type is bound to some class, then use that

2) if the generic type is not bound to some class, then use TOP to start out, 
but

    3) change this to use Annotation if the method is one of several that 
require the Annotation index, e.g. "at", or "covering", etc.

I thought I almost had a solution using <U extends Annotation & T> but that 
form isn't supported (at least in Java 8) (Note it is supported if "T" is an 
"interface")

I can't just cast the result of covering(...) to Annotation, because sometimes 
the user will have done a select(Sentence.class) and expect the result to be a 
subtype of Annotation, namely Sentence.  Furthermore, imaging the case where I 
have "Foo", a subtype of Annotation, defining myFeature, and I want to do 
aCas.select(getType(aCas, Foo.class)).covering(1, 2).filter (s -> s.myFeature > 
2) ... 

If covering cast this to Annotation, the s.myFeature would fail.  The only 
thing that would work would be to have the select learn what the type was, 
either by aCas.<Foo>select ... or aCas.select(Foo.class) .

Any suggestions on how to lower an upper bound on a generic type, only if it 
isn't "materialized" or bound to a real type, appreciated :)

> select.covering should bind to AnnotationFS
> -------------------------------------------
>
>                 Key: UIMA-6153
>                 URL: https://issues.apache.org/jira/browse/UIMA-6153
>             Project: UIMA
>          Issue Type: Improvement
>          Components: UIMA
>    Affects Versions: 3.1.1SDK
>            Reporter: Richard Eckart de Castilho
>            Priority: Major
>
> The following code does not compile because select.covering() uses TOP 
> instead of AnnotationFS as the generic type. Consequently, getBegin() and 
> getEnd() are not available on the "s" used in the filter expressions. But 
> since covering() only makes sense for annotations, binding the generic type 
> to TOP doesn't seem to make much sense:
> {{return aCas.select(getType(aCas, Sentence.class)).covering(aBegin1, 
> aBegin1)}}
> {{    .filter(s -> s.getBegin() <= aBegin1 && aBegin1 < s.getEnd())}}
> {{    .filter(s -> s.getBegin() <= aBegin2 && aBegin2 < 
> s.getEnd()).findFirst()}}
> {{    .isPresent();}}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to