"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);
assertEquals("i1",inst);
assertEquals("some",string);
} else if(i == 5) {
assertEquals(26,from);
assertEquals(34,to);
assertEquals("i11",inst);
assertEquals("word and",string);
}
i++;
}
doc.getAnnotations().removeAll(lookups);
eg.setMatchAtWordStartOnly(false);
eg.setMatchAtWordEndOnly(false);
eg.execute();
lookups = doc.getAnnotations().get("OutType");
assertEquals(22,lookups.size());
doc.getAnnotations().removeAll(lookups);
eg.setLongestMatchOnly(false);
eg.execute();
lookups = doc.getAnnotations().get("OutType");
assertEquals(26,lookups.size());
System.out.println("Gazetteer application test 1 finished for backedn "+backendNr);
}