1

I'm trying to load the pronomial coreference module using ANNIE (in Java) but I'm having some issues with the following code:

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();

After executing the pipelineController, I try to access the "MatchesAnnots" feature, or any other features, but I get an error saying Coref Warning: No annotations found for processing!. Can anyone point me in the direction of my error? Should I not be using pipelineController.setPRs()?

dedek
  • 7,981
  • 3
  • 38
  • 68
Anne Rose
  • 47
  • 4

1 Answers1

0

Your code is almost correct. The document needs pre-processing usually done by the ANNIE GATE application. That's why it is complaining about "No annotations found for processing!".

In the code bellow, I first load ANNIE and then I add the Coreferencer as the last 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"));
    }
}
dedek
  • 7,981
  • 3
  • 38
  • 68