gate
Class CookBook

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--gate.CookBook
All Implemented Interfaces:
junit.framework.Test

public class CookBook
extends junit.framework.TestCase

This class provides examples of using the GATE APIs. Read this documentation along with a copy of the source code.

The CookBook is set up as part of the GATE test suite (using the JUnit framework), so there's an easy way to run the examples (viz., gate.TestGate.main, which will invoke the JUnit test runner). Also, we can use JUnit's assert methods; e.g. assert(corpus.isEmpty()); tests that a corpus object is empty, and creates a test failure report if this is not the case. To add a new test class to the suite, see the gate.util.TestTemplate class.

Programming to the GATE Java API involves manipulating the classes and interfaces in the gate package. These are often interfaces; classes there are often to do with getting access to objects that implement the interfaces (without exposing those implementations). In other words, there's a lot of interface-based design around.

The Factory class takes care of instantiating objects that implement the interfaces, via the createResource method and various other short-cut methods for popular resource types.

GATE breaks down the components of language processing systems into three types:

Each of these types is represented by an interface, e.g. gate.LanguageResource, and the classes that implement these interfaces are known as CREOLE resources, or CREOLE components. CREOLE resources are an extendable set which can be added to and loaded at runtime.

The rest of this documentation refers to methods in the code that provide examples of using the GATE API.

The testResourceCreation method gives an example of creating a resource via gate.Factory.

The Corpus interface represents collections of Documents (and takes the place of the old TIPSTER Collection class).

The testCorpusConstruction method gives an example of how to create a new transient Corpus object.

The testAddingDocuments method gives examples of adding documents to corpora.

The testAddingAnnotations method gives examples of adding annotations to documents.

The testUsingFeatures method gives examples of using features. The FeatureMap interface is a mechanism for associating arbitrary data with GATE entities. Corpora, documents and annotations all share this mechanism. Simple feature maps use Java's Map interface.

Other sources of examples

See also the other test classes, although note that they also use methods that are not part of the public API (which is restricted to the gate package. Test classes include: TestCreole; TestCorpus; TestDocument; TestAnnotation.


Field Summary
(package private)  Corpus corpus
          A corpus
private static boolean DEBUG
          Debug flag
(package private)  Document doc1
          A document
(package private)  Document doc2
          Another document
 
Fields inherited from class junit.framework.TestCase
fName
 
Constructor Summary
CookBook(String name)
          Construction
 
Method Summary
 void setUp()
          Fixture set up: initialise members before each test method
static junit.framework.Test suite()
          Test suite routine for the test runner
 void testAddingAnnotations()
          Adding annotations to documents
 void testAddingDocuments()
          Adding documents to a corpus
 void testCorpusConstruction()
          Constructing a corpus
 void testResourceCreation()
          Constructing a resource
 void testUsingFeatures()
          Using the FeatureMap interface
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, name, run, run, runBare, runTest, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assert, assert, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, fail, fail, failNotEquals, failNotSame
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
Debug flag

corpus

Corpus corpus
A corpus

doc1

Document doc1
A document

doc2

Document doc2
Another document
Constructor Detail

CookBook

public CookBook(String name)
Construction
Method Detail

testResourceCreation

public void testResourceCreation()
                          throws GateException
Constructing a resource

testCorpusConstruction

public void testCorpusConstruction()
                            throws GateException
Constructing a corpus

testAddingDocuments

public void testAddingDocuments()
                         throws GateException
Adding documents to a corpus

testAddingAnnotations

public void testAddingAnnotations()
Adding annotations to documents

testUsingFeatures

public void testUsingFeatures()
Using the FeatureMap interface

setUp

public void setUp()
           throws GateException,
                  IOException
Fixture set up: initialise members before each test method
Overrides:
setUp in class junit.framework.TestCase

suite

public static junit.framework.Test suite()
Test suite routine for the test runner