解析GATE文档以获取共同参考文本

我正在创建一个用于查找共同引用文本的GATE应用程序。 它工作正常,我已通过GATE中提供的导出选项创建了应用程序的压缩文件。

现在我正在尝试在我的Java代码中使用相同的代码。

Gate.runInSandbox(true); Gate.setGateHome(new File(gateHome)); Gate.setPluginsHome(new File(gateHome, "plugins")); Gate.init(); URL applicationURL = new URL("file:" + new Path(gateHome, "application.xgapp").toString()); application = (CorpusController) PersistenceManager.loadObjectFromUrl(applicationURL); corpus = Factory.newCorpus("Megaki Corpus"); application.setCorpus(corpus); Document document = Factory.newDocument(text); corpus.add(document); application.execute(); corpus.clear(); 

现在我该如何解析这个文档并获得共同参考文本?

我不了解你的,但是使用Co-reference Editor手动创建的共同引用存储在文档function中 。 function名称似乎是"MatchesAnnots" ,类型为Map>>

在我的例子中,以下代码打印as name: null (默认注释集),后跟其中存在的所有共同引用链。

 Object obj = document.getFeatures().get("MatchesAnnots"); @SuppressWarnings("unchecked") Map>> map = (Map>>) obj; for (Entry>> e : map.entrySet()) { System.err.println("as name: "+ e.getKey()); for (List chain : e.getValue()) { System.err.println("chain : "+ chain); } }