Reputation: 41
I am trying to figure out a way of counting some annotations in GATE e.g. if I have some annotations occurring multiple times in a text document and if I want to count it, is there some sort of plugin that can help me?
Thanks
Upvotes: 1
Views: 215
Reputation: 494
All that is necessary is just to get these annotations and then call a .size()
method. AnnotationSet
in GATE extends Java collection classes.
AnnotationSet annotationSet = gateDocument.getAnnotations().get("ABC");
int size=annotationSet.size();
Upvotes: 1
Reputation: 1683
Another option is to use a groovy script. The code is from here:
sum = 0
docs.findAll{ // get all documents currently loaded
def filteredAnnots = it.getAnnotations("Filtered")
num = filteredAnnots["Anatomy"].size()
sum += num
println it.name + " " + num // or print to a file here
}
println "total:" + " " + sum
You can also easily put this code in a groovy plugin (PR) and run it as part of the pipeline, described here.
Upvotes: 1