Code snippets for module 5
1. Slide 6
import gate.*;
public class Main {
public static void main(String[] args)
throws Exception{
Gate.init(); // prepare the library
//create a new document
Factory.newDocument("This is a document");
}
}
2. Slide 8
package gatetutorial;
import gate.*;
import gate.gui.*;
public class Main {
public static void main(String[] args)
throws Exception{
//prepare the library
Gate.init();
//show the main window
MainFrame.getInstance().setVisible(true);
//create a document
Factory.newDocument("This is a document");
}
}
3. Slide 22
FeatureMap params = Factory.newFeatureMap();
params.put(
Document.DOCUMENT_STRING_CONTENT_PARAMETER_NAME,
"This is a document!");
FeatureMap feats = Factory.newFeatureMap();
feats.put("createdBy", "me!");
Factory.createResource("gate.corpora.DocumentImpl",
params, feats, "My first document");
4. Slide 41
//get the root plugins dir
File pluginsDir = Gate.getPluginsHome();
//Let's load the Tools plugin
File aPluginDir = new File(pluginsDir, "Tools");
//load the plugin.
Gate.getCreoleRegister().registerDirectories(
aPluginDir.toURI().toURL());