// caution: testCas gets reset fist!
public void resetAndFillTestCAS(CAS testCas, TextRulerTarget target) {
testCas.reset();
CAS docCas = getCAS();
CasCopier cc = new CasCopier(docCas, testCas);
testCas.setDocumentText(docCas.getDocumentText());
// copy all annotations except the target-annotations:
TypeSystem ts = docCas.getTypeSystem();
List<Type> slotTypes = new ArrayList<Type>();
for (String s : target.getSlotTypeNames())
slotTypes.add(ts.getType(s));
if (target.isBoundary()) {
// add the base types (without START and END markers) also !
for (String s : target.slotNames)
slotTypes.add(ts.getType(s));
}
for (AnnotationFS fs : docCas.getAnnotationIndex()) {
if (!slotTypes.contains(fs.getType())
&& !fs.getType().equals(docCas.getDocumentAnnotation().getType())) {
FeatureStructure copyFs = cc.copyFs(fs);
testCas.addFsToIndexes(copyFs);
}
}
}