This page is aimed at giving basic advice on how to use GATE and DIRE in your project. Keep in mind that GATE is much richer than what will be covered here; for more advanced advice please refer to the GATE user guide.
This page has been written using information from the GATE user guide and a bit of practice. It is in no other way related to GATE itself and does not aspire to anything other than a pragmatic retelling of what worked. You may find more efficient ways of doing what is described here, and you may find errors (and in both cases you may edit this page accordingly, while keeping its purpose of introduction into GATE).
Reminder: GATE is an english project. Do not be surprised to find english words (e.g. analyser) rather than american english (analyzer).
A GATE plugin (also known in our context as a DIRE contribution) is basically a Java package containing classes that are the resources made available by the plugin. Of course, there are a few constraints that apply.
In order to be able to develop a full-fledged plugin, you will need to install a bit of software first.
The simplest way is to launch GATE, then use
Bootstrap Wizard. The parameters are:
When you press
Finish, the whole plugin structure is created, including the
build.xml ant file.
(Warning: all these files are created using the default system encoding standard, which is most likely not unicode)
When creating the plugin, you had to provide an implementing class name. You can find this class in the src directory.
The first step is to get a functional resource class, and the necessary code is provided in the GATE manual. Just copy/paste the code in your class and make the necessary modifications. If you want to access the document being processed, ensure your class implements AbstractLanguageAnalyser. This should be the case if you pasted the example code from the manual.
Creating more resources within the plugin is as simple as creating more classes within the package.
Now in order to implement the actual function of your resource, you have three areas you must alter within the class:
You will probably have to access the document that is processed in order to add or manipulate annotations. Here is a partial class diagram of the most immediate classes you should know about, MyCustomClass being your resource class:
Here are a few more guidelines:
Correctoron the DIRE site, and please remember that it should be seen as a bad practice (hack).
To compile the plugin, use the build.xml file (either in your favorite IDE, or by calling
ant build in the plugin directory).
Testing the plugin can be done within GATE:
Manage Creole Plugins…. If your plugin is in the GATE
plugindirectory, you should find it in the list. If not, simply put it there temporarily and restart GATE. It is better not to use the directory that can be specified in the
Configurationtab, since that one is the directory where all non-GATE plugins will be installed (which is much more suited for containing the final version of your plugin, among others).
To be able to put your plugin on the DIRE repository, you must first ensure that GATE can find its version number. GATE will indeed manage the plugin update.
The version is an attribute of the
CREOLE-DIRECTORY element in the creole.xml file. In fact, you must also define an ID attribute for GATE to be able to identify your plugin. Simply put the package path as the id (it will not be displayed anywhere visible).
Here is a possible configuration:
<CREOLE-DIRECTORY ID=“fr.cnrs.liris.drim.myownplugin” VERSION=“1.0”>
For more complete information, see here.
To add a plugin to the repository, you must have access to the DIRE liris account (or find someone who has this access).
gate-update-site.xmlfile. Simply add a
<CreolePlugin url=“DirectoryName/” />.
You can then verify that the plugin appears when launching GATE (see the following sections).
Configurationtab specify a directory for the installed plugins. Then use the
+button to add the DIRE repository (
http://liris.cnrs.fr/dire/gate/gate-update-site.xml) to the list of Plugin Repositories. Ensure that the newly-added DIRE repository is enabled. Click the
Available to Installtab, select the plugins you want to install. Click the
Apply Allbutton again.
Installed Pluginstab, find the newly-installed plugins and select
Plugins that can be updated will be displayed in the
ManageCreole Plugins… →
Available Updates tab.
Installed Plugins, click the
Apply Allbutton (all resource from these plugins should disappear both from the
New…menu and from the Resources tree).
Available Updatestab, select the plugins and click once more on
Installed Pluginstab, find the newly-updated plugins and reactivate them (select
Like before, in order to be able to use GATE within a project, you will need to install GATE first, along with any plugin you would like to use. See the previous sections for the latter.
There are to ways of embedding GATE into your project:
You will also have to fetch the plugins you intend to use, by either:
System.setProperty(“gate.site.config”, “./gate.xml”);if you copy a gate.xml file into your project directory)
This must be done before any call to GATE within the code.
In order to use GATE, you will have to:
A code example is available to illustrate this process. It uses our RSSParser GATE plugin to read and annotate the content of an RSS feed, and deals with the other issues: getting the feed from the user, scheduling the content refreshing, enforcing said schedule and outputting the content in a suitable html style.
The annotated code of the class dealing directly with GATE is available here and the full application is available as a Netbeans project here.
Note that in order to make it work without modification, you must have the Toolkit_RSS plugin installed in a directory named
plugins_dire within your GATE install directory, and you may have to manually include the libraries again.
Further code examples can be found on the GATE site itself.