Skip to content

Commit fc7372c

Browse files
J38Stanford NLP
authored andcommitted
fix inline xml bug for single token entities
1 parent 2f8b308 commit fc7372c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/edu/stanford/nlp/pipeline/InlineXMLOutputter.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@ private static void print(Annotation annotation, PrintWriter pw, Options options
4040
pw.printf(" ");
4141
}
4242
if (numEntities > entityIdx) {
43-
if (entities.get(entityIdx).charOffsets().first() == token.beginPosition())
43+
if (entities.get(entityIdx).charOffsets().first() == token.beginPosition()) {
4444
pw.printf("<%s>%s", entities.get(entityIdx).entityType(), token.word());
45-
else if (entities.get(entityIdx).charOffsets().second() == token.endPosition()) {
45+
// handle single token entities
46+
if (entities.get(entityIdx).charOffsets().second() == token.endPosition()) {
47+
pw.printf("<%s>", entities.get(entityIdx).entityType());
48+
entityIdx++;
49+
}
50+
} else if (entities.get(entityIdx).charOffsets().second() == token.endPosition()) {
4651
pw.printf("%s<%s>", token.word(), entities.get(entityIdx).entityType());
4752
entityIdx++;
4853
} else {

0 commit comments

Comments
 (0)