Fox -o option for -T with docker taggers
Change-Id: Ia6dbbe506ea5cae8debaa9216b9fa11e1ff233ec
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 22cf3c9..685ee60 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,8 +4,7 @@
### Fixed
-- `-o` option for CoNLL-U output
-
+- `-o <outputfile>` option, now has the highest priority for specifying the output file path
- missing newlines in file output for now, w2v, conllu target formats when using `-o` option
### Added
diff --git a/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXmlTool.kt b/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXmlTool.kt
index a2ee6a2..c0f8dba 100644
--- a/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXmlTool.kt
+++ b/app/src/main/kotlin/de/ids_mannheim/korapxmltools/KorapXmlTool.kt
@@ -710,12 +710,8 @@
if (outputFormat == OutputFormat.KRILL) {
// Determine output path for Krill format
krillOutputPath = if (outputFile != null) {
- // Use explicit -o option
- val finalOutputPath = if (outputDir != ".") {
- File(outputDir, File(outputFile!!).name).path
- } else {
- outputFile!!
- }
+ // Use explicit -o option - has highest priority, use as-is
+ val finalOutputPath = outputFile!!
// Ensure .tar extension for Krill format
if (finalOutputPath.endsWith(".tar")) {
finalOutputPath
@@ -779,11 +775,8 @@
throw ParameterException(spec.commandLine(),
"Reading from stdin requires -o/--output to specify output file path")
}
- val finalOutputPath = if (outputDir != ".") {
- File(outputDir, File(outputFile!!).name).path
- } else {
- outputFile!!
- }
+ // -o has highest priority - use it as-is (absolute or relative to CWD)
+ val finalOutputPath = outputFile!!
LOGGER.info("Converting CoNLL-U from stdin to: $finalOutputPath")
convertConlluToZip(System.`in`, finalOutputPath)
return 0
@@ -794,12 +787,8 @@
zipFileNames!!.forEach { conlluFile ->
val outputPath = when {
outputFile != null -> {
- // Explicit -o specified: use outputDir if specified
- if (outputDir != ".") {
- File(outputDir, File(outputFile!!).name).path
- } else {
- outputFile!!
- }
+ // -o has highest priority - use it as-is (absolute or relative to CWD)
+ outputFile!!
}
else -> {
// Auto-infer from input filename
@@ -829,11 +818,8 @@
// Normal ZIP processing mode
if (outputFile != null && (outputFormat == OutputFormat.CONLLU || outputFormat == OutputFormat.WORD2VEC || outputFormat == OutputFormat.NOW)) {
- val finalOutputPath = if (outputDir != ".") {
- File(outputDir, File(outputFile!!).name).path
- } else {
- outputFile!!
- }
+ // -o has highest priority - use it as-is (absolute or relative to CWD)
+ val finalOutputPath = outputFile!!
val file = File(finalOutputPath)
if (file.exists()) {
if (!overwrite) {
@@ -1244,7 +1230,8 @@
val targetFoundry = externalFoundry ?: "annotated"
val baseZipName = File(inputZipPath).name.replace(Regex("\\.zip$"), "")
- val outputMorphoZipFileName = File(outputDir, "$baseZipName.$targetFoundry.zip").absolutePath
+ val autoOutputFileName = File(outputDir, "$baseZipName.$targetFoundry.zip").absolutePath
+ val outputMorphoZipFileName = outputFile ?: autoOutputFileName
targetZipFileName = outputMorphoZipFileName
// Check for existing output file BEFORE redirecting logging, so user sees the message
diff --git a/app/src/test/kotlin/de/ids_mannheim/korapxmltools/FoundryOverrideTest.kt b/app/src/test/kotlin/de/ids_mannheim/korapxmltools/FoundryOverrideTest.kt
index fa882ce..d0ee9cb 100644
--- a/app/src/test/kotlin/de/ids_mannheim/korapxmltools/FoundryOverrideTest.kt
+++ b/app/src/test/kotlin/de/ids_mannheim/korapxmltools/FoundryOverrideTest.kt
@@ -99,7 +99,7 @@
}
}
- @Ignore("This test is ignored until -o is fixed")
+ @Test
fun testOutputOptionHasPriority() {
val outputDir = File.createTempFile("output_option_test", "").apply {
delete()