1
15
16 package gate.creole.coref;
17
18 import java.util.List;
19
20 import junit.framework.*;
21
22 import gate.*;
23 import gate.creole.ANNIETransducer;
24 import gate.creole.POSTagger;
25 import gate.creole.gazetteer.DefaultGazetteer;
26 import gate.creole.orthomatcher.OrthoMatcher;
27 import gate.creole.splitter.SentenceSplitter;
28 import gate.creole.tokeniser.DefaultTokeniser;
29
30 public class TestCoref extends TestCase {
31
32 public TestCoref(String name) {
33 super(name);
34 }
35
36 public static void main(String[] args) {
37
38 try{
39 Gate.init();
40 TestCoref testCoref = new TestCoref("");
41
42 testCoref.setUp();
43 testCoref.useCase01();
44 testCoref.tearDown();
45
46 } catch(Exception e) {
47 e.printStackTrace();
48 }
49 }
51
52
53 public static Test suite() {
54 return new TestSuite(TestCoref.class);
55 }
57
58 public void setUp() throws Exception {
59 }
60
61 public void tearDown() throws Exception {
62 }
64
65 private void runANNIE(Document doc) throws Exception {
66 System.out.println("starting ANNIE modules...");
67 DefaultTokeniser englishTokeniser = (DefaultTokeniser)Factory.createResource("gate.creole.tokeniser.DefaultTokeniser");
68 DefaultGazetteer gazeteer = (DefaultGazetteer)Factory.createResource("gate.creole.gazetteer.DefaultGazetteer");
69 SentenceSplitter split = (SentenceSplitter)Factory.createResource("gate.creole.splitter.SentenceSplitter");
70 POSTagger tag = (POSTagger)Factory.createResource("gate.creole.POSTagger");
71 ANNIETransducer neTransducer = (ANNIETransducer)Factory.createResource("gate.creole.ANNIETransducer");
72 OrthoMatcher orthoMatcher = (OrthoMatcher)Factory.createResource("gate.creole.orthomatcher.OrthoMatcher");
73
74 englishTokeniser.init();
75 gazeteer.init();
76 split.init();
77 tag.init();
78 neTransducer.init();
79 orthoMatcher.init();
80
81 englishTokeniser.setDocument(doc);
82 gazeteer.setDocument(doc);
83 split.setDocument(doc);
84 tag.setDocument(doc);
85 neTransducer.setDocument(doc);
86 orthoMatcher.setDocument(doc);
87
88 englishTokeniser.execute();
89 gazeteer.execute();
90 split.execute();
91 tag.execute();
92 neTransducer.execute();
93 orthoMatcher.execute();
94
95 }
96
97
98 private Document loadDocument(String url)
99 throws Exception {
100
101 FeatureMap params = Factory.newFeatureMap(); params.clear();
104 params.put(Document.DOCUMENT_URL_PARAMETER_NAME, url);
105
106 Document doc = (Document) Factory.createResource("gate.corpora.DocumentImpl", params);
108
109 return doc;
110 }
111
112
113
114 public void useCase01()
115 throws Exception{
116 System.out.println("starting use case 01...");
117
118 DataStore sds = Factory.openDataStore("gate.persist.SerialDataStore", "file:/E:/gate2/serial/debug/");
119 sds.open();
120
121 List lrIds = sds.getLrIds("gate.corpora.DocumentImpl");
122 Object lrID = lrIds.get(0);
123
124 Document doc = (Document) sds.getLr("gate.corpora.DocumentImpl", lrID);
125
129
131 Coreferencer corefMain = (Coreferencer)Factory.createResource("gate.creole.coref.Coreferencer");
132 corefMain.init();
133 corefMain.setDocument(doc);
134 System.out.println("starting COREF...");
135 corefMain.execute();
136 System.out.println("case 01 finished...");
137 return;
138 }
140 }
141