Check sentence index for out of bounds
Change-Id: I99d63d541f9a008b190759d1e0bb93d7bde45f21
diff --git a/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXml2Conllu.kt b/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXml2Conllu.kt
index 022923a..1a63b32 100644
--- a/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXml2Conllu.kt
+++ b/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXml2Conllu.kt
@@ -413,7 +413,7 @@
}
tokens[docId]?.forEach { span ->
token_index++
- if (span.from >= sentences[docId]!![sentence_index].to) {
+ if (sentence_index >= sentences[docId]!!.size || span.from >= sentences[docId]!![sentence_index].to) {
if(output.isNotEmpty()) {
output.setCharAt(output.length - 1, '\n')
} else {
@@ -449,7 +449,7 @@
}
tokens[docId]?.forEach { span ->
token_index++
- if (span.from >= sentences[docId]!![sentence_index].to) {
+ if (sentence_index >= sentences[docId]!!.size || span.from >= sentences[docId]!![sentence_index].to) {
output.append("\n")
sentence_index++
token_index = 1