我一直试图了解如何在位于gate.corpora.DocumentJsonUtils的GATE中使用JSON导出程序。有人能提供一个有用的例子吗?我不太清楚在哪里找到或者如何构造Map<String,Collection<Annotation>> annotationsMap,这是所有方法所需要的。
发布于 2017-04-06 16:19:35
这是为我解决问题的“快速”黑客。不知道他们为什么决定这个特定的数据结构。另外,也不确定为什么这不是作为默认选项在内部完成的,因为它是从文档派生的。
¯\_(ツ)_/
public static String makeJson(Document doc) {
AnnotationSet as = doc.getAnnotations();
Map<String, Collection<Annotation>> anns = new HashMap<>();
anns.put("MyAnnotations", as.inDocumentOrder());
try {
return DocumentJsonUtils.toJson(doc, anns);
} catch (IOException ex) {
return "";
}
}https://stackoverflow.com/questions/43255126
复制相似问题