-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestCoreferenceModelLoader.java
74 lines (58 loc) · 2.09 KB
/
TestCoreferenceModelLoader.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package de.unistuttgart.ims.coref.annotator.worker;
import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.util.prefs.Preferences;
import org.apache.uima.UIMAException;
import org.apache.uima.cas.impl.XmiCasDeserializer;
import org.apache.uima.fit.factory.JCasFactory;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.tcas.Annotation;
import org.junit.Before;
import org.junit.Test;
import org.xml.sax.SAXException;
import de.unistuttgart.ims.coref.annotator.CoreferenceModelListener;
import de.unistuttgart.ims.coref.annotator.api.Entity;
import de.unistuttgart.ims.coref.annotator.api.EntityGroup;
import de.unistuttgart.ims.coref.annotator.document.CoreferenceModel;
public class TestCoreferenceModelLoader {
JCas jcas;
CoreferenceModelListener modelListener;
@Before
public void setUp() {
modelListener = new CoreferenceModelListener() {
@Override
public void annotationEvent(Event event, Annotation annotation) {
// TODO Auto-generated method stub
}
@Override
public void entityEvent(Event event, Entity entity) {
// TODO Auto-generated method stub
}
@Override
public void entityGroupEvent(Event event, EntityGroup entity) {
// TODO Auto-generated method stub
}
@Override
public void annotationMovedEvent(Annotation annotation, Object from, Object to) {
// TODO Auto-generated method stub
}
};
}
@Test
public void testLoading() throws UIMAException, SAXException, IOException {
testResource("/rjmw.0.xmi");
testResource("/Text_1804.xmi");
testResource("/DieLeidenDesJungenWerther.xmi");
testResource("/Annika+Bearbeitung+4.xmi");
testResource("/Rowlandson_Tanja.xmi");
}
public void testResource(String s) throws UIMAException, SAXException, IOException {
jcas = JCasFactory.createJCas();
XmiCasDeserializer.deserialize(getClass().getResourceAsStream(s), jcas.getCas(), true);
DocumentModelLoader cml = new DocumentModelLoader(cm -> {
}, jcas);
CoreferenceModel model = cml.load(Preferences.userRoot()).getCoreferenceModel();
assertNotNull(model);
assertNotNull(model.getMentions(20));
}
}