Search code examples
javagate

Calling Existing PipeLine in GATE


I am new to Java and I want to call my saved pipeline using GATE JAVA API through Eclipse I am not sure how I could do this although I know how to create new documents etc

FeatureMap params = Factory.newFeatureMap();
params.put(Document.DOCUMENT_URL_PARAMETER_NAME, new URL("http://www.gate.ac.uk"));
params.put(Document.DOCUMENT_ENCODING_PARAMETER_NAME, "UTF-8");

// document features
FeatureMap feats = Factory.newFeatureMap();
feats.put("date", new Date());
Factory.createResource("gate.corpora.DocumentImpl", params, feats, "This is home");

//End Solution 2
// obtain a map of all named annotation sets
Document doc = Factory.newDocument("Document text");
Map <String, AnnotationSet> namedASes = doc.getNamedAnnotationSets();
System.out.println("No. of named Annotation Sets:" + namedASes.size());

// no of annotations each set contains
for (String setName : namedASes.keySet()) {
// annotation set
AnnotationSet aSet = namedASes.get(setName);
// no of annotations
System.out.println("No. of Annotations for " +setName + ":" + aSet.size());

Solution

  • There is a good example of GATE usage from java. Probably it does exactly what you want. BatchProcessApp.java. In particular: loading pipeline is done with lines

    // load the saved application
    CorpusController application =
      (CorpusController)PersistenceManager.loadObjectFromFile(gappFile);
    

    pipeli executed with

    // run the application
      application.execute();
    

    Code is informative, clear and could be easy changed for your particular needs. The oxygen of open source project :)