【发布时间】:2017-04-06 12:23:02
【问题描述】:
我一直在尝试了解如何在位于gate.corpora.DocumentJsonUtils 的 GATE 中使用 JSON 导出器。有人可以提供一个工作示例吗?我不太确定在哪里可以找到或如何构造所有方法都需要的Map<String,Collection<Annotation>> annotationsMap。
【问题讨论】:
标签: gate
我一直在尝试了解如何在位于gate.corpora.DocumentJsonUtils 的 GATE 中使用 JSON 导出器。有人可以提供一个工作示例吗?我不太确定在哪里可以找到或如何构造所有方法都需要的Map<String,Collection<Annotation>> annotationsMap。
【问题讨论】:
标签: gate
这是为我解决这个问题的“快速”技巧。不知道他们为什么决定采用这种特定的数据结构。也不知道为什么这不是在内部作为默认选项在内部完成,因为它是从文档派生的。
¯\_(ツ)_/¯
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 "";
}
}
【讨论】: