【问题标题】:GATE: A working example for gate.corpora.DocumentJsonUtilsGATE:gate.corpora.DocumentJsonUtils 的工作示例
【发布时间】:2017-04-06 12:23:02
【问题描述】:

我一直在尝试了解如何在位于gate.corpora.DocumentJsonUtils 的 GATE 中使用 JSON 导出器。有人可以提供一个工作示例吗?我不太确定在哪里可以找到或如何构造所有方法都需要的Map<String,Collection<Annotation>> annotationsMap

【问题讨论】:

    标签: gate


    【解决方案1】:

    这是为我解决这个问题的“快速”技巧。不知道他们为什么决定采用这种特定的数据结构。也不知道为什么这不是在内部作为默认选项在内部完成,因为它是从文档派生的。

    ¯\_(ツ)_/¯

      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 "";
        }
      }
    

    【讨论】:

    猜你喜欢
    • 2011-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-24
    • 2016-08-14
    • 2021-08-16
    • 2012-08-14
    • 2016-11-09
    相关资源
    最近更新 更多