1

I have developed an application using Gate Developer, which apply paum algorithm and display the results in a new annotation set called "output" having an annotation called "comment".

Then, I imported this application on Gate Embedded. However, the "output" annotation set generated with Gate Embedded doesn't have any annotation!

EDIT
This is how I proceeded:

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

I then tried to check if the "output" annotation set contains something:

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
}

The corpus is the same as the one I used in Gate Developer. In Gate developer, I had "output" annotation set with features but not in Gate Embedded. I want to understand why this is happening.

EDIT
Below is a screenshot of what I get in Gate Developer. After applying the PR, an annotation set called "output" having an annotation called "comment" is created.
But in Gate Embedded, I don't have this "comment" annotation.

enter image description here

Thank you in advance,

celineu
  • 576
  • 1
  • 5
  • 18

1 Answers1

2

It sounds to me like you're getting confused between the annotation set and the annotation type - annotation sets don't themselves have features. If what you're seeing in the GATE Developer annotation sets tree is

enter image description here

then you don't have an annotation set called "output" but rather annotations of type "output" in the default annotation set (which has no name). To access these you'd use code like

for(Document document:listDocument) {
    AnnotationSet annSet = document.getAnnotations().get("output");
Ian Roberts
  • 120,891
  • 16
  • 170
  • 183
  • Sorry, I haven't formulated my question very well... I mean that I have an annotation set called "output" (which is not in the default annotation set). But this "output" annotation set doesn't display any annotation after I execute the application in Gate Embedded, while on Gate Developer, it has some... – celineu Apr 17 '15 at 11:10
  • Thanks for your reply. I have added a picture of my result using Gate Developer (which I don't get in Gate Embedded) in my question to illustrate my problem. – celineu Apr 17 '15 at 11:20
  • @celineu how are you setting up the application in your embedded code? Is it definitely configured the same in both cases (the safest way to operate is to save your application state in Developer and then load it into your embedded code using the `PersistenceManager`) – Ian Roberts Apr 17 '15 at 11:37
  • I loaded the application using: `CorpusController applicationGate = (CorpusController) PersistenceManager.loadObjectFromFile(new File("E_Reputation/application.xgapp"));` The application has been exported to a zip file (using "Export for GateCloud.net" in Gate Developer), then copied and unzipped in the Java project root. – celineu Apr 17 '15 at 11:40
  • In Gate Developer, the "output" annotation set is created when setting outputAsName=output in the configuration of the Batch Learning PR. – celineu Apr 17 '15 at 11:46
  • It seems like either the batch learning PR isn't executed, either the whole application isn't working. Which is strange since it work fine on Gate Developer... – celineu Apr 17 '15 at 13:38
  • 1
    @celineu I take it you're testing in both cases on the same data? I agree that the two cases ought to behave the same, but I don't personally know enough about the learning PR to say for sure. It may be worth trying to dump out the document as GATE XML from your embedded code, so you can load it into developer for testing and know that it's exactly the same data in both cases. – Ian Roberts Apr 17 '15 at 13:56
  • 1
    I found it's because I have to create the "Key" annotation set as follow: `doc.getAnnotations("Key").add(start, end, "comment", Factory.newFeatureMap());` and call the new annotation "comment" (I forgot to give it a name). Otherwise, the batch learning PR won't find on which annotation to work on. It was a big mistake that I didn't catch... The answer was pretty obvious after importing the XML of my embedded code in Gate developer. Thank you for your advice! – celineu Apr 17 '15 at 14:07