1   /*
2    *  TestCoref.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   *  Marin Dimitrov, 02/01/2002
12   *
13   *  $Id: TestCoref.java,v 1.5 2002/03/06 17:15:42 kalina Exp $
14   */
15  
16  package gate.creole.coref;
17  
18  import java.util.*;
19  
20  import junit.framework.*;
21  
22  import gate.*;
23  import gate.util.*;
24  import gate.corpora.*;
25  import gate.creole.*;
26  import gate.creole.tokeniser.*;
27  import gate.creole.gazetteer.*;
28  import gate.creole.splitter.*;
29  import gate.creole.orthomatcher.*;
30  import gate.creole.coref.*;
31  
32  public class TestCoref extends TestCase {
33  
34    public TestCoref(String name) {
35      super(name);
36    }
37  
38    public static void main(String[] args) {
39  
40      try{
41        Gate.init();
42        TestCoref testCoref = new TestCoref("");
43  
44        testCoref.setUp();
45        testCoref.useCase01();
46        testCoref.tearDown();
47  
48      } catch(Exception e) {
49        e.printStackTrace();
50      }
51    } // main
52  
53  
54    /** Test suite routine for the test runner */
55    public static Test suite() {
56      return new TestSuite(TestCoref.class);
57    } // suite
58  
59    /** Fixture set up */
60    public void setUp() throws Exception {
61    }
62  
63    public void tearDown() throws Exception {
64    } // tearDown
65  
66  
67    private void runANNIE(Document doc) throws Exception {
68  System.out.println("starting ANNIE modules...");
69      DefaultTokeniser englishTokeniser = (DefaultTokeniser)Factory.createResource("gate.creole.tokeniser.DefaultTokeniser");
70      DefaultGazetteer gazeteer = (DefaultGazetteer)Factory.createResource("gate.creole.gazetteer.DefaultGazetteer");
71      SentenceSplitter split = (SentenceSplitter)Factory.createResource("gate.creole.splitter.SentenceSplitter");
72      POSTagger tag = (POSTagger)Factory.createResource("gate.creole.POSTagger");
73      ANNIETransducer neTransducer = (ANNIETransducer)Factory.createResource("gate.creole.ANNIETransducer");
74      OrthoMatcher orthoMatcher = (OrthoMatcher)Factory.createResource("gate.creole.orthomatcher.OrthoMatcher");
75  
76      englishTokeniser.init();
77      gazeteer.init();
78      split.init();
79      tag.init();
80      neTransducer.init();
81      orthoMatcher.init();
82  
83      englishTokeniser.setDocument(doc);
84      gazeteer.setDocument(doc);
85      split.setDocument(doc);
86      tag.setDocument(doc);
87      neTransducer.setDocument(doc);
88      orthoMatcher.setDocument(doc);
89  
90      englishTokeniser.execute();
91      gazeteer.execute();
92      split.execute();
93      tag.execute();
94      neTransducer.execute();
95      orthoMatcher.execute();
96  
97    }
98  
99  
100   private Document loadDocument(String url)
101     throws Exception {
102 
103     FeatureMap params = Factory.newFeatureMap(); // params list for new doc
104     // set the source URL parameter to a "file:..." URL string
105     params.clear();
106     params.put(Document.DOCUMENT_URL_PARAMETER_NAME, url);
107 
108     // create the document
109     Document doc = (Document) Factory.createResource("gate.corpora.DocumentImpl", params);
110 
111     return doc;
112   }
113 
114 
115   /** Test suite routine for the test runner */
116   public void useCase01()
117     throws Exception{
118 System.out.println("starting use case 01...");
119 
120     DataStore sds = Factory.openDataStore("gate.persist.SerialDataStore", "file:/E:/gate2/serial/debug/");
121     sds.open();
122 
123     List lrIds = sds.getLrIds("gate.corpora.DocumentImpl");
124     Object lrID = lrIds.get(0);
125 
126     Document doc = (Document) sds.getLr("gate.corpora.DocumentImpl", lrID);
127 //    Document doc = loadDocument("file:/E:/Gate2/data/gatecorpora/ace/aps/npaper/clean/9801.35.sgm");
128 //    Document doc = loadDocument("file:/E:/Gate2/data/gatecorpora/ace/aps/npaper/clean/9806.93.sgm");
129 //    Document doc = loadDocument("file:/E:/Gate2/data/gatecorpora/ace/aps/npaper/clean/9802.108.sgm");
130 
131 //--    runANNIE(doc);
132 
133     Coreferencer corefMain = (Coreferencer)Factory.createResource("gate.creole.coref.Coreferencer");
134     corefMain.init();
135     corefMain.setDocument(doc);
136 System.out.println("starting COREF...");
137     corefMain.execute();
138 System.out.println("case 01 finished...");
139     return;
140   } // suite
141 
142 }
143