@@ -111,7 +111,7 @@ private static void checkResult(Annotation annotation,
111111 }
112112 }
113113
114- private static void checkInvert (Annotation annotation , String gold ) {
114+ private static void checkBeforeInvert (Annotation annotation , String gold ) {
115115 List <CoreLabel > annotationLabels =
116116 annotation .get (CoreAnnotations .TokensAnnotation .class );
117117 StringBuilder original = new StringBuilder ();
@@ -124,6 +124,18 @@ private static void checkInvert(Annotation annotation, String gold) {
124124 assertEquals (gold , original .toString ());
125125 }
126126
127+ private static void checkAfterInvert (Annotation annotation , String gold ) {
128+ List <CoreLabel > annotationLabels =
129+ annotation .get (CoreAnnotations .TokensAnnotation .class );
130+ StringBuilder original = new StringBuilder ();
131+ original .append (annotationLabels .get (0 ).get (CoreAnnotations .BeforeAnnotation .class ));
132+ for (CoreLabel label : annotationLabels ) {
133+ original .append (label .get (CoreAnnotations .OriginalTextAnnotation .class ));
134+ original .append (label .get (CoreAnnotations .AfterAnnotation .class ));
135+ }
136+ assertEquals (gold , original .toString ());
137+ }
138+
127139 private static void checkContext (CoreLabel label , String ... expectedContext ) {
128140 List <String > xmlContext = label .get (CoreAnnotations .XmlContextAnnotation .class );
129141 assertEquals (expectedContext .length , xmlContext .size ());
@@ -216,17 +228,20 @@ public void testInvertible() {
216228 Annotation annotation = annotate (testNoTags , ptbInvertible ,
217229 cleanXmlAllTags , wtsSplitter );
218230 checkResult (annotation , testNoTags );
219- checkInvert (annotation , testNoTags );
231+ checkBeforeInvert (annotation , testNoTags );
232+ checkAfterInvert (annotation , testNoTags );
220233
221234 annotation = annotate (testTags , ptbInvertible ,
222235 cleanXmlAllTags , wtsSplitter );
223236 checkResult (annotation , testNoTags );
224- checkInvert (annotation , testTags );
237+ checkBeforeInvert (annotation , testTags );
238+ checkAfterInvert (annotation , testTags );
225239
226240 annotation = annotate (testManyTags , ptbInvertible ,
227241 cleanXmlAllTags , wtsSplitter );
228242 checkResult (annotation , testNoTags );
229- checkInvert (annotation , testManyTags );
243+ checkBeforeInvert (annotation , testManyTags );
244+ checkAfterInvert (annotation , testManyTags );
230245 }
231246
232247 @ Test
@@ -287,7 +302,8 @@ public void testViaCoreNlp() {
287302 StanfordCoreNLP pipeline = new StanfordCoreNLP (props );
288303 pipeline .annotate (anno );
289304
290- checkInvert (anno , testManyTags );
305+ checkBeforeInvert (anno , testManyTags );
306+ checkAfterInvert (anno , testManyTags );
291307 List <CoreLabel > annotationLabels =
292308 anno .get (CoreAnnotations .TokensAnnotation .class );
293309 for (int i = 0 ; i < 3 ; ++i ) {
0 commit comments