Fix race condition with metadata extraction
Change-Id: Icf4ad479c2d862075741a14d63d871c455f9e49c
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 998d071..28d0fd2 100644
--- a/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXml2Conllu.kt
+++ b/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXml2Conllu.kt
@@ -369,10 +369,9 @@
if (texts[docId] != null && sentences[docId] != null && tokens[docId] != null
&& (!waitForMorpho || morpho[docId] != null)
- && (extractMetadataRegex.isEmpty() || metadata.containsKey(docId))
+ && (extractMetadataRegex.isEmpty() || metadata[docId] != null)
) {
processText(docId, foundry, waitForMorpho)
-
}
} else if (extractMetadataRegex.isNotEmpty() && zipEntry.name.matches(Regex(".*/header\\.xml$"))) {
//LOGGER.info("Processing header file: " + zipEntry.name)
@@ -390,6 +389,11 @@
}
if (meta.isNotEmpty() && docId != null) {
metadata[docId] = meta.toTypedArray()
+ if (texts[docId] != null && sentences[docId] != null && tokens[docId] != null
+ && (!waitForMorpho || morpho[docId] != null)
+ ) {
+ processText(docId, foundry, waitForMorpho)
+ }
}
}
} catch (e: Exception) {