8
8
import org .apache .uima .fit .descriptor .ConfigurationParameter ;
9
9
import org .apache .uima .fit .util .JCasUtil ;
10
10
import org .apache .uima .jcas .JCas ;
11
+ import org .apache .uima .jcas .cas .FSArray ;
11
12
import org .dkpro .core .api .io .ResourceCollectionReaderBase ;
12
13
import org .dkpro .core .api .resources .CompressionUtils ;
13
14
import org .eclipse .collections .api .map .MutableMap ;
21
22
import de .unistuttgart .ims .coref .annotator .TypeSystemVersion ;
22
23
import de .unistuttgart .ims .coref .annotator .api .v2 .Entity ;
23
24
import de .unistuttgart .ims .coref .annotator .api .v2 .Mention ;
25
+ import de .unistuttgart .ims .coref .annotator .api .v2 .MentionSurface ;
24
26
import de .unistuttgart .ims .coref .annotator .api .v2 .Segment ;
25
27
import de .unistuttgart .ims .coref .annotator .api .v2 .tei .TEIBody ;
26
28
import de .unistuttgart .ims .coref .annotator .api .v2 .tei .TEIHeader ;
@@ -60,23 +62,37 @@ public void getNext(CAS aCAS) {
60
62
gxr .addGlobalRule ("titleStmt > title:first-child" , (d , e ) -> d .setDocumentTitle (e .text ()));
61
63
62
64
// characters declared in the header (GerDraCor)
63
- gxr .addGlobalRule ("profileDesc [xml:id]" , Mention .class , (m , e ) -> {
65
+ gxr .addGlobalRule ("profileDesc [xml:id]" , MentionSurface .class , (ms , e ) -> {
64
66
Entity cf = new Entity (jcas );
65
67
cf .addToIndexes ();
66
68
cf .setLabel (e .attr ("xml:id" ));
67
69
cf .setColor (colorProvider .getNextColor ().getRGB ());
68
70
entityMap .put (e .attr ("xml:id" ), cf );
71
+ Mention m = new Mention (jcas );
72
+ m .addToIndexes ();
73
+
74
+ m .setSurface (new FSArray <MentionSurface >(jcas , 1 ));
75
+ m .setSurface (0 , ms );
76
+ m .getSurface ().addToIndexes ();
69
77
m .setEntity (cf );
78
+ ms .setMention (m );
70
79
});
71
80
72
81
// other entities declared in the text (QuaDramA legacy)
73
- gxr .addGlobalRule ("text [xml:id]" , Mention .class , (m , e ) -> {
82
+ gxr .addGlobalRule ("text [xml:id]" , MentionSurface .class , (ms , e ) -> {
74
83
Entity cf = new Entity (jcas );
75
84
cf .addToIndexes ();
76
85
cf .setLabel (e .attr ("xml:id" ));
77
86
cf .setColor (colorProvider .getNextColor ().getRGB ());
78
87
entityMap .put (e .attr ("xml:id" ), cf );
88
+ Mention m = new Mention (jcas );
89
+ m .addToIndexes ();
90
+
91
+ m .setSurface (new FSArray <MentionSurface >(jcas , 1 ));
92
+ m .setSurface (0 , ms );
93
+ m .getSurface ().addToIndexes ();
79
94
m .setEntity (cf );
95
+ ms .setMention (m );
80
96
});
81
97
82
98
gxr .addRule ("text speaker" , Speaker .class );
@@ -85,7 +101,13 @@ public void getNext(CAS aCAS) {
85
101
gxr .addRule ("TEI > text > body" , TEIBody .class );
86
102
87
103
// entity references
88
- gxr .addRule ("text rs[ref]" , Mention .class , (m , e ) -> {
104
+ gxr .addRule ("text rs[ref]" , MentionSurface .class , (ms , e ) -> {
105
+ Mention m = new Mention (jcas );
106
+ m .addToIndexes ();
107
+ m .setSurface (new FSArray <MentionSurface >(jcas , 1 ));
108
+ m .setSurface (0 , ms );
109
+ m .getSurface ().addToIndexes ();
110
+ ms .setMention (m );
89
111
String id = e .attr ("ref" ).substring (1 );
90
112
Entity entity = entityMap .get (id );
91
113
if (entity == null ) {
@@ -100,8 +122,14 @@ public void getNext(CAS aCAS) {
100
122
});
101
123
102
124
// entity references (QuaDramA legacy)
103
- gxr .addRule ("text name[ref]" , Mention .class , (m , e ) -> {
125
+ gxr .addRule ("text name[ref]" , MentionSurface .class , (ms , e ) -> {
104
126
String id = e .attr ("ref" ).substring (1 );
127
+ Mention m = new Mention (jcas );
128
+ m .setSurface (new FSArray <MentionSurface >(jcas , 1 ));
129
+ m .setSurface (0 , ms );
130
+ m .getSurface ().addToIndexes ();
131
+ m .addToIndexes ();
132
+ ms .setMention (m );
105
133
Entity entity = entityMap .get (id );
106
134
if (entity == null ) {
107
135
entity = new Entity (jcas );
@@ -115,8 +143,15 @@ public void getNext(CAS aCAS) {
115
143
});
116
144
117
145
// identify speaker tags
118
- gxr .addRule ("text speaker" , Mention .class , (m , e ) -> {
146
+ gxr .addRule ("text speaker" , MentionSurface .class , (ms , e ) -> {
119
147
Element parent = e .parent ();
148
+ Mention m = new Mention (jcas );
149
+ m .setSurface (new FSArray <MentionSurface >(jcas , 1 ));
150
+ m .setSurface (0 , ms );
151
+ m .getSurface ().addToIndexes ();
152
+ m .addToIndexes ();
153
+ ms .setMention (m );
154
+
120
155
if (parent .hasAttr ("who" )) {
121
156
String id = parent .attr ("who" ).substring (1 );
122
157
Entity entity = entityMap .get (id );
0 commit comments