throws MalformedURLException, ResourceInstantiationException, ExecutionException {
do_testGazetteerApplication1(3);
}
public void do_testGazetteerApplication1(int backendNr) throws MalformedURLException, ResourceInstantiationException, ExecutionException {
System.out.println("Running gazetteer application test 1 for backend "+backendNr);
FeatureMap parms = Factory.newFeatureMap();
File defFile = new File(testingDir,"extgaz2.def");
URL gazURL = defFile.toURI().toURL();
parms.put("configFileURL", gazURL);
parms.put("backendNr",backendNr);
ExtendedGazetteer2 eg = (ExtendedGazetteer2)Factory.createResource(
"com.jpetrak.gate.stringannotation.extendedgazetteer2.ExtendedGazetteer2", parms);
// load the document
parms = Factory.newFeatureMap();
File docFile = new File(testingDir,"extgaz2docprep.xml");
parms.put("sourceUrl",docFile.toURI().toURL());
Document doc = (Document)
Factory.createResource("gate.corpora.DocumentImpl", parms);
AnnotationSet lookups = doc.getAnnotations().get("OutType");
assertEquals(0,lookups.size());
// run the gazetteer on the document
eg.setDocument(doc);
eg.execute();
// check if we got the correct annotations
AnnotationSet tokens = doc.getAnnotations().get("Token");
assertEquals(46,tokens.size());
AnnotationSet sentences = doc.getAnnotations().get("Sentence");
assertEquals(4,sentences.size());
lookups = doc.getAnnotations().get("OutType");
if(backendNr == 3) {
assertEquals(12,lookups.size());
} else {
assertEquals(14,lookups.size());
}
int i = 1;
FeatureMap fm;
long from;
long to;
for(Annotation ann : gate.Utils.inDocumentOrder(lookups)) {
//System.out.println("Annotation: "+ann);
fm = ann.getFeatures();
String inst = (String)fm.get("inst");
String string = (String)fm.get("_string");
from = ann.getStartNode().getOffset();
to = ann.getEndNode().getOffset();
if(i == 1) {
assertEquals(8,from);
assertEquals(12,to);