You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by Marshall Schor <ms...@schor.com> on 2009/08/07 14:17:27 UTC

Is the generification supertype of AnnotationIndex.iterator() correct?

AnnotationIndex interface extends
  FSIndex<AnnotationFS> extends
    Iterable<AnnotationFS>.

Iterable interface defines one method,
  iterator<T> where T is AnnotationFS (in this case).

AnnotationIndexImpl implements AnnotationIndex.

Therefore, it has a method, iterator, whose return value is
FSIterator<AnnotationFS>.

-----------

The hierarchy of feature structure interfaces leading to AnnotationFS:

  FeatureStructure - most general
    AnnotationBaseFS - adds view/sofa info ref
      AnnotationFS - adds begin and end as "integer" valued slots

This design is intended to support other kinds of annotations with begin
and end defined as, for instance, "float" values.  One use case is
having a SOFA be an audio stream, and the begin/end representing time
oriented subparts of the stream.

These values could be indexed, etc., just like AnnotationFS instances
could, with an appropriate index (using float rather than int values).

-----------

The current choice in generification doesn't support this; a fix would
be to change AnnotationIndex generification from
 public interface AnnotationIndex extends FSIndex<AnnotationFS> to
 public interface AnnotationIndex extends FSIndex<AnnotationBaseFS>
 
Is this correct?

-Marshall   
   




Re: Is the generification supertype of AnnotationIndex.iterator() correct?

Posted by Marshall Schor <ms...@schor.com>.
Jörn Kottmann wrote:
>
>> The current choice in generification doesn't support this; a fix would
>> be to change AnnotationIndex generification from
>>  public interface AnnotationIndex extends FSIndex<AnnotationFS> to
>>  public interface AnnotationIndex extends FSIndex<AnnotationBaseFS>
>>  
>> Is this correct?
>>   
> The reason I choose AnnotationFS was that the javadoc says:
>
> "An annotation index provides additional iterator functionality that
> applies only to instances of
> uima.tcas.Annotation."
>
> The type uima.tcas.Annotation has int begin and end features, which is
> represented
> as AnnotationFS.
>
> Wouldn't it be a violation to the API if it can also contain non
> uima.tcas.Annotation FSes ?

Yes, I think you are correct.  I was confused about how we were
generalizing things.
>
> But maybe we should also consider changing the interface to something
> like this:
> public interface AnnotationIndex<T extends Annotation(Base)FS> extends
> FSIndex<T>
>

Yes, that fixes user code (see my other note).
-Marshall
> Jörn
>
>

Re: Is the generification supertype of AnnotationIndex.iterator() correct?

Posted by Jörn Kottmann <ko...@gmail.com>.
> The current choice in generification doesn't support this; a fix would
> be to change AnnotationIndex generification from
>  public interface AnnotationIndex extends FSIndex<AnnotationFS> to
>  public interface AnnotationIndex extends FSIndex<AnnotationBaseFS>
>  
> Is this correct?
>   
The reason I choose AnnotationFS was that the javadoc says:

"An annotation index provides additional iterator functionality that 
applies only to instances of
uima.tcas.Annotation."

The type uima.tcas.Annotation has int begin and end features, which is 
represented
as AnnotationFS.

Wouldn't it be a violation to the API if it can also contain non 
uima.tcas.Annotation FSes ?

But maybe we should also consider changing the interface to something 
like this:
public interface AnnotationIndex<T extends Annotation(Base)FS> extends 
FSIndex<T>

Jörn