} catch (Exception e) {
LOG.error("Can't generate GATE doc from binary content", e);
}
}
FeatureMap params = Factory.newFeatureMap();
params.put(Document.DOCUMENT_STRING_CONTENT_PARAMETER_NAME,
inputDoc.getText());
// no need to generate markup from it
params.put(Document.DOCUMENT_MARKUP_AWARE_PARAMETER_NAME, Boolean.FALSE);
gatedocument = (Document) Factory.createResource(
"gate.corpora.DocumentImpl", params);
gatedocument.setSourceUrl(null);
// then the metadata as document features
FeatureMap docFeatures = gatedocument.getFeatures();
String docUrl = inputDoc.getUrl();
if (docUrl != null)
docFeatures.put("gate.SourceURL", docUrl);
if (inputDoc.getMetadata() != null) {
Iterator<Entry<Writable, Writable>> iter = inputDoc.getMetadata()
.entrySet().iterator();
while (iter.hasNext()) {
Entry<Writable, Writable> entry = iter.next();
String skey = entry.getKey().toString().trim();
String svalue = null;
if (entry.getValue() != null)
svalue = entry.getValue().toString().trim();
docFeatures.put(skey, svalue);
}
}
// finally the annotations to the GATE document
String GATEAnnotationSetName = getConf().get(
"gate.annotationset.input", "Original markups");
AnnotationSet outputAS = gatedocument
.getAnnotations(GATEAnnotationSetName);
for (Annotation annot : inputDoc.getAnnotations()) {
// add to outputAS as a GATE annotation
FeatureMap features = Factory.newFeatureMap();
features.putAll(annot.getFeatures());
outputAS.add(annot.getStart(), annot.getEnd(), annot.getType(),
features);
}
return gatedocument;
}