GATE 加载处理资源/代词解析
GATE Loading Processing Resources / Pronoun Resolution
我正在尝试使用 ANNIE(在 Java 中)加载 pronomial coreference module,但我在使用以下代码时遇到了一些问题:
FeatureMap params = Factory.newFeatureMap();
params.put("resolveIt", "true");
ProcessingResource coref = (ProcessingResource) Factory.createResource("gate.creole.coref.Coreferencer", params);
Collection<ProcessingResource> processingResources = new ArrayList<ProcessingResource>();
processingResources.add(coref);
pipelineController.setPRs(processingResources);
params.clear();
params.put("sourceUrl", url); # this is the url of a test document
params.put("collectRepositioningInfo", new Boolean(true));
Document doc = (Document) Factory.createResource("gate.corpora.DocumentImpl", params);
corpus.add(doc);
pipelineController.setCorpus(corpus);
pipelineController.execute();
执行 pipelineController 后,我尝试访问 "MatchesAnnots" 功能或任何其他功能,但我收到一条错误消息,提示 Coref 警告:未找到要处理的注释!.谁能指出我错误的方向?我不应该使用 pipelineController.setPRs() 吗?
您的代码几乎是正确的。 文档需要预处理,通常由 ANNIE GATE 应用程序完成。这就是为什么它抱怨 "No annotations found for processing!".
在下面的代码中,我首先加载 ANNIE,然后添加 Coreferencer
作为最后一个 PR。
import java.io.File;
import gate.*;
import gate.creole.ConditionalSerialAnalyserController;
import gate.util.persistence.PersistenceManager;
public class CoreferencerTest {
public static void main(String[] args) throws Exception {
Gate.setGateHome(new File("C:\Program Files\GATE_Developer_8.4"));
Gate.init();
//load ANNIE GATE app
Object gapp = PersistenceManager.loadObjectFromFile(
new File(Gate.getPluginsHome(), "ANNIE/ANNIE_with_defaults.gapp"));
ConditionalSerialAnalyserController pipelineController = (ConditionalSerialAnalyserController) gapp;
//add Coreferencer to the end of ANNIE
ProcessingResource coref = (ProcessingResource) Factory.createResource(
"gate.creole.coref.Coreferencer", Utils.featureMap("resolveIt", true));
pipelineController.add(coref);
//execute it
Corpus corpus = Factory.newCorpus("corpus name");
Document doc = Factory.newDocument("Peter was driving his car.");
corpus.add(doc);
pipelineController.setCorpus(corpus);
pipelineController.execute();
//see the result
System.err.println(doc.getFeatures().get("MatchesAnnots"));
}
}
我正在尝试使用 ANNIE(在 Java 中)加载 pronomial coreference module,但我在使用以下代码时遇到了一些问题:
FeatureMap params = Factory.newFeatureMap();
params.put("resolveIt", "true");
ProcessingResource coref = (ProcessingResource) Factory.createResource("gate.creole.coref.Coreferencer", params);
Collection<ProcessingResource> processingResources = new ArrayList<ProcessingResource>();
processingResources.add(coref);
pipelineController.setPRs(processingResources);
params.clear();
params.put("sourceUrl", url); # this is the url of a test document
params.put("collectRepositioningInfo", new Boolean(true));
Document doc = (Document) Factory.createResource("gate.corpora.DocumentImpl", params);
corpus.add(doc);
pipelineController.setCorpus(corpus);
pipelineController.execute();
执行 pipelineController 后,我尝试访问 "MatchesAnnots" 功能或任何其他功能,但我收到一条错误消息,提示 Coref 警告:未找到要处理的注释!.谁能指出我错误的方向?我不应该使用 pipelineController.setPRs() 吗?
您的代码几乎是正确的。 文档需要预处理,通常由 ANNIE GATE 应用程序完成。这就是为什么它抱怨 "No annotations found for processing!".
在下面的代码中,我首先加载 ANNIE,然后添加 Coreferencer
作为最后一个 PR。
import java.io.File;
import gate.*;
import gate.creole.ConditionalSerialAnalyserController;
import gate.util.persistence.PersistenceManager;
public class CoreferencerTest {
public static void main(String[] args) throws Exception {
Gate.setGateHome(new File("C:\Program Files\GATE_Developer_8.4"));
Gate.init();
//load ANNIE GATE app
Object gapp = PersistenceManager.loadObjectFromFile(
new File(Gate.getPluginsHome(), "ANNIE/ANNIE_with_defaults.gapp"));
ConditionalSerialAnalyserController pipelineController = (ConditionalSerialAnalyserController) gapp;
//add Coreferencer to the end of ANNIE
ProcessingResource coref = (ProcessingResource) Factory.createResource(
"gate.creole.coref.Coreferencer", Utils.featureMap("resolveIt", true));
pipelineController.add(coref);
//execute it
Corpus corpus = Factory.newCorpus("corpus name");
Document doc = Factory.newDocument("Peter was driving his car.");
corpus.add(doc);
pipelineController.setCorpus(corpus);
pipelineController.execute();
//see the result
System.err.println(doc.getFeatures().get("MatchesAnnots"));
}
}