Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Translations of uimaFIT select methods to the new API

Format: the samples not in a box are uimaFIT styles; in the boxes are possible new API styles (sometimes multiples), with some commentary.

select

Convenience method to iterator over all features structures of a given type.

select(JCas, Class<T>)
Code Block
languagejava
jcas.select() // selects an implicit index,
              // starts with top level default bag index
              // switches to AnnotationIndex if any subsequent build operations imply needing this
              // switches to explicitly specified index if subsequently specified
              // can subsequently specify a top-level type (must be the type or a subtype of the type defined in the index)
 
jcas.select(Token.class)  // note: in UV3, these should also work with cas (not just with jcas)? 
                          //       We're trying to reduce the distinction between these because it's less needed in UV3.
jcas.select(Token.type)
jcas.select("my.package.Token") 
 
for (Token.class : jcas.select(Token.class)) {
  ...
}
 
jcas.select(Token.class).forEach( t -> System.out.println(t) );
jcas.select(Token.class).forEach(System.out::println);      
select(FSArray, Class<T>)
select(FSList, Class<T>
Code Block
languagejava
myArray.select(Token.class)  // select also on arrays and fslists
myList.select(Token.class)  
myIndex.select(FSList, Class<T>

...

Code Block
languagejava
myListmyIndex.select(Token.class)  // select also works on uima indexes
selectAll

Convenience method to iterator iterate over all features structures indexed in a particular index in a particular view. 
(.allViews()) not part of uimaFIT). 

selectAll(JCas)
Code Block
languagejava
jcas.select() // leave off type specification
selectAt

Get all annotations of the given type at the specified offsets. 

Does this mean covered-by (limit the FSs returned) or startAt - no limit?

selectAt(JCas, Class<T>, int, int)

...

Code Block
languagejava
jcas.select(Token.class).between(fs1, fs2) // might make more sense because we are using offsets, not index positions
jcas.select(Token.class).startAt(fs1).endAt(fs2) // this looks more like index positions...
 
selectByIndex
selectByIndex(JCas, Class<T>, int)
Code Block
languagejava
jcas.select(Token.class).atskip(indexPosition)  // skip is standard stream operator
selectCovered

Get a list of annotations of the given annotation type constrained by a 'covering' annotation. Iterates over all annotations of the given type to find the covered annotations. Does not use subiterators.

The covering annotation is never returned itself, even if it is of the queried-for type or a subtype of that type.
Not sure why this is special-cased? 

selectCovered(Class<T>, AnnotationFS)

...

Code Block
languagejava
jcas.select(Token.class).within(contextAnnotation) // within is variant of coveredby
selectCovered(JCas, Class<T>, int, int)

...

Code Block
languagejava
 jcas.select(Token.class).containing(contextAnnotation) // containing is variant of covering
selectCovering(JCas, Class<T>, int, int)

...

Code Block
languagejava
jcas.select(Token.class).startAt(contextAnnotation).limit(10) // it is IMHO not entirely clear here that contextAnnotation is not included in the result...
jcas.select(Token.class).seek(contextAnnotation).skip(1).limit(10) // somehow too complex...
jcas.select(Token.class).following(contextAnnotation).limit(10)
jcas.select().following(10, fs)  // the 10 FSs >= fs
jcas.select().preceding(3, 10, 100)  // the 3 FSs < a bounding FS with begin=10, end=100, in reverse order(?)
jcas.select().following(10, fs, -3) // the 10 FSs >= { fs , after a -3 offset }
selectPreceding

Returns the n annotations preceding the given annotation.

...

Code Block
languagejava
jcas.select(Token.class).startAt(contextAnnotation).reverse().limit(10)
jcas.select(Token.class).startAt(contextAnnotation).limit(-10) // probably not because limit is standard stream method
                                                               // throws exception on negative arg
selectSingle

Get the single instance of the specified type from the JCas.

...

Code Block
languagejava
jcas.select(DocumentMetaData.class).single()
jcas.select(DocumentMetaData.class).single().getDocumentUri()
jcas.select(DocumentMetaData.type).get()  // alternative name
jcas.select(DocumentMetaData.type).get(1) // arg is offset
selectSingleAt

Get a single annotations of the given type at the specified offsets.

...