| TestGazetteer |

    1   /*
    2    *  TestGazetteer.java
    3    *
    4    *  Copyright (c) 1998-2001, The University of Sheffield.
    5    *
    6    *  This file is part of GATE (see http://gate.ac.uk/), and is free
    7    *  software, licenced under the GNU Library General Public License,
    8    *  Version 2, June 1991 (in the distribution as file licence.html,
    9    *  and also available at http://gate.ac.uk/gate/licence.html).
    10   *
    11   *  Valentin Tablan, 25/10/2000
    12   *
    13   *  $Id: TestGazetteer.java,v 1.11 2001/10/30 12:45:36 valyt Exp $
    14   */
    15
    16  package gate.creole.gazetteer;
    17
    18  import java.util.*;
    19  import java.io.*;
    20  import java.net.*;
    21  import java.beans.*;
    22  import java.lang.reflect.*;
    23  import junit.framework.*;
    24
    25  import gate.*;
    26  import gate.util.*;
    27  import gate.corpora.TestDocument;
    28
    29  public class TestGazetteer extends TestCase {
    30
    31    public TestGazetteer(String name) {
    32      super(name);
    33    }
    34
    35    /** Fixture set up */
    36    public void setUp() throws Exception {
    37    }
    38
    39    public void tearDown() throws Exception {
    40    } // tearDown
    41
    42    /** Test the default tokeniser */
    43    public void testDefaultGazetteer() throws Exception {
    44      //get a document
    45      Document doc = Factory.newDocument(
    46        new URL(TestDocument.getTestServerName() + "tests/doc0.html")
    47      );
    48
    49      //create a default gazetteer
    50      FeatureMap params = Factory.newFeatureMap();
    51      params.put("listsURL", new URL("gate:/creole/gazeteer/default/lists.def"));
    52      DefaultGazetteer gaz = (DefaultGazetteer) Factory.createResource(
    53                            "gate.creole.gazetteer.DefaultGazetteer", params);
    54
    55      //runtime stuff
    56      gaz.setDocument(doc);
    57      gaz.setAnnotationSetName("GazetteerAS");
    58      gaz.execute();
    59      assertTrue(!doc.getAnnotations("GazetteerAS").isEmpty());
    60    }
    61
    62    /** Test suite routine for the test runner */
    63    public static Test suite() {
    64      return new TestSuite(TestGazetteer.class);
    65    } // suite
    66
    67    public static void main(String[] args) {
    68      try{
    69        Gate.init();
    70        TestGazetteer testGaz = new TestGazetteer("");
    71        testGaz.setUp();
    72        testGaz.testDefaultGazetteer();
    73        testGaz.tearDown();
    74      } catch(Exception e) {
    75        e.printStackTrace();
    76      }
    77    } // main
    78
    79  } // TestGazetteer
    80

| TestGazetteer |