【问题标题】:Gate Developer and Gate Embedded difference in outputGate Developer 和 Gate Embedded 的输出差异
【发布时间】:2015-04-17 10:19:24
【问题描述】:

我使用Gate Developer 开发了一个应用程序,它应用了 paum 算法并将结果显示在一个名为“output”的新注释集中,其中包含一个名为“comment”的注释。

然后,我在 Gate Embedded 上导入了这个应用程序。 但是,使用 Gate Embedded 生成的“输出”注释集没有任何注释!

编辑
我是这样处理的:

ArrayList<Tweet> listTweets = ...
ArrayList<Document> listDocument = new ArrayList<Document>();

//initialize Gate library
Gate.setGateHome(new File("E_Reputation/"));
Gate.setPluginsHome(new File("E_Reputation/plugins/"));
Gate.setUserConfigFile(new File("config/user-gate.xml"));
Gate.setSiteConfigFile(new File("config/site-gate.xml"));
Gate.init();

//load Gate application
CorpusController applicationGate = (CorpusController) PersistenceManager.loadObjectFromFile(new File("E_Reputation/application.xgapp"));
corpus = Factory.newCorpus("Tweets");corpus = Factory.newCorpus("Tweets");

//populate the corpus
for(i=0;i<listTweets.size();i++) {
            //Document doc = Factory.newDocument(listTweets.get(i).getText());
            FeatureMap params = Factory.newFeatureMap();
            params.put(Document.DOCUMENT_STRING_CONTENT_PARAMETER_NAME,listTweets.get(i).getText());
            Document doc = (Document) Factory.createResource("gate.corpora.DocumentImpl", params);

            Long start=gate.Utils.start(doc);
            Long end = gate.Utils.end(doc);
            doc.getAnnotations("Key").add(start, end, " ", Factory.newFeatureMap());
            listDocument.add(doc);
            corpus.add(listDocument.get(i));
}

//execute Gate application
applicationGate.setCorpus(corpus);
applicationGate.execute();

然后我尝试检查“输出”注释集是否包含某些内容:

for(Document document:listDocument) {

        Set<String> allAnnSet = document.getAnnotationSetNames();
        System.out.println(allAnnSet.contains("output")); // return true
        AnnotationSet annSet = document.getAnnotations("output");
        List<Annotation> listAnn = annSet.inDocumentOrder();
        System.out.println(annSet.size());                // return 0
        System.out.println(listAnn.size());               // return 0
}

语料库与我在 Gate Developer 中使用的语料库相同。在 Gate 开发人员中,我设置了带有特性的“输出”注释集,但在 Gate Embedded 中没有。我想了解为什么会这样。

编辑
下面是我在 Gate Developer 中得到的截图。 应用 PR 后,会创建一个名为“output”的注释集,其中包含一个名为“comment”的注释。
但是在 Gate Embedded 中,我没有这个“评论”注释。

提前谢谢你,

【问题讨论】:

    标签: java gate


    【解决方案1】:

    在我看来,您在注释 set 和注释 type 之间感到困惑 - 注释 sets 本身没有特征。如果您在 GATE Developer 注释集树中看到的是

    那么您在默认注释集中(没有名称)中没有称为“输出”的注释set,而是type“输出”的注释。要访问这些,您可以使用类似

    的代码
    for(Document document:listDocument) {
        AnnotationSet annSet = document.getAnnotations().get("output");
    

    【讨论】:

    • 对不起,我没有很好地表达我的问题......我的意思是我有一个名为“输出”的注释集(不在默认注释集中)。但是这个“输出”注释集在我在 Gate Embedded 中执行应用程序后不显示任何注释,而在 Gate Developer 中,它有一些......
    • 感谢您的回复。我在我的问题中添加了一张使用 Gate Developer(我没有在 Gate Embedded 中获得)的结果图片来说明我的问题。
    • @celineu 您如何在嵌入式代码中设置应用程序?在这两种情况下是否确实配置相同(最安全的操作方式是在Developer中保存您的应用程序状态,然后使用PersistenceManager将其加载到您的嵌入式代码中)
    • @celineu 我认为您在两种情况下都在对相同的数据进行测试?我同意这两种情况应该表现相同,但我个人对学习 PR 的了解还不够,无法肯定地说。尝试将文档作为 GATE XML 从您的嵌入式代码中转储出来可能是值得的,这样您就可以将其加载到开发人员中进行测试,并且知道它在两种情况下都是完全相同的数据。
    • 我发现这是因为我必须创建如下的“Key”注释集:doc.getAnnotations("Key").add(start, end, "comment", Factory.newFeatureMap()); 并将新注释称为“comment”(我忘了给它命名)。否则,批量学习 PR 将找不到要处理的注释。这是我没有发现的一个大错误……在 Gate developer 中导入我的嵌入式代码的 XML 后,答案非常明显。谢谢你的建议!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多