Fix buffer flushing to work with tei2korapxml
Change-Id: I54eef64bea40f4ebb528e7f9870b9277000a4c13
diff --git a/token_writer.go b/token_writer.go
index bccb1bd..39d97fa 100644
--- a/token_writer.go
+++ b/token_writer.go
@@ -106,6 +106,7 @@
} else if flags&SENTENCES != 0 {
tw.SentenceEnd = func(_ int) {
writer.WriteByte('\n')
+ writer.Flush()
}
// Ignore sentence boundaries
@@ -116,7 +117,6 @@
// Write token or sentence positions
if flags&(TOKEN_POS|SENTENCE_POS) != 0 {
tw.TextEnd = func(_ int) {
- writer.Flush()
// Write token positions
if flags&TOKEN_POS != 0 {
@@ -140,6 +140,8 @@
sentB = true
}
+ writer.Flush()
+
posC = 0
pos = pos[:0]
}