0

我对UIMA很满意,但我的新工作要求我使用GATE

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

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

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

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

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

4

1 回答 1

0

此代码似乎有助于将注释写入 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");
于 2013-08-23T17:41:02.283 回答