Table of Contents

Using DIRE and GATE

Introduction / Disclaimer

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).

Creating and managing a GATE Plugin

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.

Preparing GATE

In order to be able to develop a full-fledged plugin, you will need to install a bit of software first.

Creating a plugin

The simplest way is to launch GATE, then use ToolsBootstrap 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)

Developing a resource within a plugin

First steps

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.

Coding

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:

Within the GATE document you will access, this translates as the following object structure (the example annotations are taken from the output of a tokeniser):

Here are a few more guidelines:

Compiling and Testing

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:

Lifecycle of a plugin within the DIRE platform

Versioning

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.

Adding a plugin to the DIRE repository

To add a plugin to the repository, you must have access to the DIRE liris account (or find someone who has this access).

You can then verify that the plugin appears when launching GATE (see the following sections).

Installing plugins from the DIRE repository

Updating the DIRE plugins

Plugins that can be updated will be displayed in the FileManageCreole Plugins…Available Updates tab.

Using GATE within a larger application

Preparing GATE

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:

Loading GATE into a java project

As covered in the corresponding part of the GATE manual, you will have to include the GATE libraries in the project (/bin/gate.jar and the content of /lib), or use the Maven repository.

You will also have to fetch the plugins you intend to use, by either:

This must be done before any call to GATE within the code.

Running GATE within the project

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.