curoffset += actualSeparatorString.length();
}
}
}
FeatureMap theparms = Factory.newFeatureMap();
theparms.put("collectRepositioningInfo", document.getCollectRepositioningInfo());
theparms.put("encoding", ((DocumentImpl) document).getEncoding());
theparms.put("markupAware", document.getMarkupAware());
theparms.put("mimeType", ((DocumentImpl) document).getMimeType());
theparms.put("preserveOriginalContent", document.getPreserveOriginalContent());
theparms.put("stringContent", newText.toString());
FeatureMap thefeats = Factory.newFeatureMap();
FeatureMap docfeats = document.getFeatures();
thefeats.putAll(docfeats);
String theName = document.getName();
// create a copy of the current document
Document newDoc;
try {
newDoc = (Document) Factory.createResource(
"gate.corpora.DocumentImpl",
theparms,
thefeats,
theName+"_virtual");
} catch (ResourceInstantiationException ex) {
throw new GateRuntimeException(ex);
}
// set the initial annotations in the virtual document
AnnotationSet newSet = newDoc.getAnnotations(virtualSpecificationSet);
for(AnnotationSpec annspec : annspecs) {
FeatureMap fm = Factory.newFeatureMap();
fm.putAll(annspec.annotation.getFeatures());
fm.put("orig_id",annspec.origId);
try {
newSet.add(annspec.fromOffset, annspec.toOffset, virtualSpecificationType, fm);
} catch(InvalidOffsetException ex) {
throw new GateRuntimeException(
"Invalid offset when creating annotation for virtual document: from/to/doclength: "+