@@ -124,28 +124,19 @@ public String printSemanticGraph(SemanticGraph basicSg, SemanticGraph enhancedSg
124
124
125
125
// don't use after() directly; it returns a default of ""
126
126
// TODO: also print SpacesBefore on the first token
127
- if (token .get (CoreAnnotations .AfterAnnotation .class ) != null ) {
127
+ Boolean isMWT = token .get (CoreAnnotations .IsMultiWordTokenAnnotation .class );
128
+ if ((isMWT == null || !isMWT ) && token .get (CoreAnnotations .AfterAnnotation .class ) != null ) {
128
129
String after = token .after ();
129
130
if (!after .equals (" " )) {
130
131
if (after .equals ("" )) {
131
132
after = "SpaceAfter=No" ;
132
133
} else {
133
134
after = "SpacesAfter=" + escapeSpaces (after );
134
135
}
135
- IndexedWord nextVertex = tokenSg .getNodeByIndexSafe (token .index () + 1 );
136
- // the next word needs to exist and be part of the same MWT
137
- // and either this word is the start of the MWT
138
- // or this word is the middle of the same MWT as the next word
139
- // if that is true, we will skip the SpaceAfter annotation
140
- boolean inMWT = ((nextVertex != null && isMWTbutNotStart (nextVertex )) &&
141
- ((token .containsKey (CoreAnnotations .IsFirstWordOfMWTAnnotation .class ) && token .get (CoreAnnotations .IsFirstWordOfMWTAnnotation .class )) ||
142
- (isMWTbutNotStart (token ))));
143
- if (!inMWT ) {
144
- if (misc .equals ("_" )) {
145
- misc = after ;
146
- } else {
147
- misc = misc + "|" + after ;
148
- }
136
+ if (misc .equals ("_" )) {
137
+ misc = after ;
138
+ } else {
139
+ misc = misc + "|" + after ;
149
140
}
150
141
}
151
142
}
@@ -224,7 +215,31 @@ public static void printMWT(StringBuilder sb, SemanticGraph graph, IndexedWord t
224
215
return ;
225
216
}
226
217
String range = String .format ("%d-%d" , startIndex , endIndex );
227
- sb .append (String .format ("%s\t %s\t _\t _\t _\t _\t _\t _\t _\t _%n" , range , token .get (CoreAnnotations .MWTTokenTextAnnotation .class )));
218
+
219
+ IndexedWord endVertex = graph .getNodeByIndexSafe (endIndex );
220
+
221
+ String misc = "_" ;
222
+ if (token .get (CoreAnnotations .MWTTokenMiscAnnotation .class ) != null ) {
223
+ misc = token .get (CoreAnnotations .MWTTokenMiscAnnotation .class );
224
+ }
225
+
226
+ if (endVertex .get (CoreAnnotations .AfterAnnotation .class ) != null ) {
227
+ String after = endVertex .after ();
228
+ if (!after .equals (" " )) {
229
+ if (after .equals ("" )) {
230
+ after = "SpaceAfter=No" ;
231
+ } else {
232
+ after = "SpacesAfter=" + escapeSpaces (after );
233
+ }
234
+ if (misc .equals ("_" )) {
235
+ misc = after ;
236
+ } else {
237
+ misc = misc + "|" + after ;
238
+ }
239
+ }
240
+ }
241
+
242
+ sb .append (String .format ("%s\t %s\t _\t _\t _\t _\t _\t _\t _\t %s%n" , range , token .get (CoreAnnotations .MWTTokenTextAnnotation .class ), misc ));
228
243
}
229
244
230
245
/**
0 commit comments