public class GateGroovyMethods extends Object
Constructor and Description |
---|
GateGroovyMethods() |
Modifier and Type | Method and Description |
---|---|
static <T> List<T> |
collect(gate.Corpus self,
groovy.lang.Closure<T> closure)
Call the closure once for each document in this corpus, loading
and unloading documents as appropriate in the case of a persistent
corpus, and collecting the return values of each call into a list.
|
static <T> Collection<T> |
collect(gate.Corpus self,
Collection<T> coll,
groovy.lang.Closure<T> closure)
Call the closure once for each document in this corpus, loading
and unloading documents as appropriate in the case of a persistent
corpus, and adding the return values of each call to the given
collection.
|
static <T> Object |
each(gate.Corpus self,
groovy.lang.Closure<T> closure)
Call the closure once for each document in this corpus, loading
and unloading documents as appropriate in the case of a persistent
corpus.
|
static <T> Object |
eachWithIndex(gate.Corpus self,
groovy.lang.Closure<T> closure)
Call the closure once for each document in this corpus, loading
and unloading documents as appropriate in the case of a persistent
corpus.
|
static gate.AnnotationSet |
getAt(gate.AnnotationSet self,
groovy.lang.Range<?> range)
Sub-range access for annotation sets (mapping to getContained).
|
static gate.DocumentContent |
getAt(gate.DocumentContent self,
groovy.lang.Range<?> range)
Sub-range access for document content.
|
static gate.AnnotationSet |
getAt(gate.SimpleAnnotationSet self,
List<String> types)
Array-style access for annotation sets.
|
static gate.AnnotationSet |
getAt(gate.SimpleAnnotationSet self,
String type)
Array-style access for annotation sets.
|
static <T> T |
withResource(gate.Resource self,
groovy.lang.Closure<T> closure)
Call the given closure passing this resource as a parameter,
and ensuring that the resource is deleted when the closure
returns.
|
public static <T> List<T> collect(gate.Corpus self, groovy.lang.Closure<T> closure)
self
- the corpus to traverseclosure
- the closure to callpublic static <T> Collection<T> collect(gate.Corpus self, Collection<T> coll, groovy.lang.Closure<T> closure)
self
- the corpus to traverseclosure
- the closure to callpublic static <T> Object each(gate.Corpus self, groovy.lang.Closure<T> closure)
self
- the corpus to traverseclosure
- the closure to callpublic static <T> Object eachWithIndex(gate.Corpus self, groovy.lang.Closure<T> closure)
self
- the corpus to traverseclosure
- the closure to callpublic static gate.AnnotationSet getAt(gate.AnnotationSet self, groovy.lang.Range<?> range)
someAnnotationSet[15..20]
. This works with ranges
whose end points are any numeric type, so as well as using integer
literals you can do someAnnotationSet[ann.start()..ann.end()]
(as start and end return Long).AnnotationSet.getContained(Long, Long)
public static gate.DocumentContent getAt(gate.DocumentContent self, groovy.lang.Range<?> range)
documentContent[15..20]
. This works with ranges
whose end points are any numeric type, so as well as using integer
literals you can do documentContent[ann.start()..ann.end()]
(as start and end return Long).self
- range
- public static gate.AnnotationSet getAt(gate.SimpleAnnotationSet self, String type)
someAnnotationSet["Token"]
SimpleAnnotationSet.get(String)
public static gate.AnnotationSet getAt(gate.SimpleAnnotationSet self, List<String> types)
someAnnotationSet["Token", "SpaceToken"]
SimpleAnnotationSet.get(Set)
public static <T> T withResource(gate.Resource self, groovy.lang.Closure<T> closure)
Factory.newDocument(someUrl).withResource { // do something with the document (it) }
self
- closure
-