【问题标题】:How to store and compare annotation (with Gold Standard) in GATE如何在 GATE 中存储和比较注释(使用黄金标准)
【发布时间】:2013-08-22 21:39:23
【问题描述】:

我对@9​​87654321@ 很满意,但是我的新工作要求我使用GATE

所以,我开始学习 GATE。我的问题是关于如何计算我的标记引擎(基于 java)的性能。

使用 UIMA,我通常将所有系统注释转储到 xmi 文件中,然后使用 Java 代码将其与人工注释(黄金标准)注释进行比较,以计算 Precision/Recall 和 F 分数。

但是,我仍在努力寻找与 GATE 类似的东西。 在浏览了Gate Annotation-Diff 和该页面上的其他信息之后,我觉得必须有一种简单的方法可以在 JAVA 中完成。但是,我无法弄清楚如何使用 JAVA 来做到这一点。想把这个问题放在这里,可能有人已经想通了。

  1. 如何以编程方式将系统注释存储到 xmi 或任何格式文件中。
  2. 如何创建一次性黄金标准数据(即人工注释数据)用于性能计算。

如果您需要更具体或更详细的信息,请告诉我。

【问题讨论】:

    标签: annotations nlp text-mining gate uima


    【解决方案1】:

    此代码似乎有助于将注释写入 xml 文件。 http://gate.ac.uk/wiki/code-repository/src/sheffield/examples/BatchProcessApp.java

            String docXMLString = null;
            // if we want to just write out specific annotation types, we must
            // extract the annotations into a Set
            if(annotTypesToWrite != null) {
                // Create a temporary Set to hold the annotations we wish to write out
                Set annotationsToWrite = new HashSet();
    
                // we only extract annotations from the default (unnamed) AnnotationSet
                // in this example
                AnnotationSet defaultAnnots = doc.getAnnotations();
                Iterator annotTypesIt = annotTypesToWrite.iterator();
                while(annotTypesIt.hasNext()) {
                    // extract all the annotations of each requested type and add them to
                    // the temporary set
                    AnnotationSet annotsOfThisType =
                            defaultAnnots.get((String)annotTypesIt.next());
                    if(annotsOfThisType != null) {
                        annotationsToWrite.addAll(annotsOfThisType);
                    }
                }
    
                // create the XML string using these annotations
                docXMLString = doc.toXml(annotationsToWrite);
            }
            // otherwise, just write out the whole document as GateXML
            else {
                docXMLString = doc.toXml();
            }
    
            // Release the document, as it is no longer needed
            Factory.deleteResource(doc);
    
            // output the XML to <inputFile>.out.xml
            String outputFileName = docFile.getName() + ".out.xml";
            File outputFile = new File(docFile.getParentFile(), outputFileName);
    
            // Write output files using the same encoding as the original
            FileOutputStream fos = new FileOutputStream(outputFile);
            BufferedOutputStream bos = new BufferedOutputStream(fos);
            OutputStreamWriter out;
            if(encoding == null) {
                out = new OutputStreamWriter(bos);
            }
            else {
                out = new OutputStreamWriter(bos, encoding);
            }
    
            out.write(docXMLString);
    
            out.close();
            System.out.println("done");
    

    【讨论】:

      猜你喜欢
      • 2015-09-19
      • 1970-01-01
      • 2019-02-05
      • 2022-06-13
      • 1970-01-01
      • 2013-11-09
      • 1970-01-01
      • 1970-01-01
      • 2013-02-09
      相关资源
      最近更新 更多