From 1f8971773422ec1dd7b91ef73d5349340be2df46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Pluta?= Date: Thu, 8 Jan 2026 14:33:49 +0100 Subject: [PATCH] Enable passing options to subcommands --- index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index d22925f..ef83ae0 100755 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ const { spawnSync } = require("child_process"); -async function analyse(input) { - const { stdout } = spawnSync(MORFEUSZ_ANALYSER_BIN, [], { input }); +async function analyse(input, ...args) { + const { stdout } = spawnSync(MORFEUSZ_ANALYSER_BIN, args, { input }); const linePattern = /^\s?(?\[)?(?\d+),(?\d+),(?,|(.+?)),(?,|(.+?)),(?[\w:.]+),(?_|(.+?)),(?_|(.+?))(?\])?$/; @@ -38,8 +38,8 @@ async function analyse(input) { return output; } -async function runConcraftLocally(input) { - const { stdout, stderr } = spawnSync(CONCRAFT_BIN, ["tag", CONCRAFT_MODEL], { input }); +async function runConcraftLocally(input, ...args) { + const { stdout, stderr } = spawnSync(CONCRAFT_BIN, ["tag", CONCRAFT_MODEL, ...args], { input }); const error = stderr.toString(); @@ -65,7 +65,7 @@ async function invokeConcraftRemotely(dag) { return data.dag; } -async function desambiguate(analysis) { +async function desambiguate(analysis, ...args) { const input = analysis .flatMap(a => a) .map(a => ({ ...a, tags: Object.values(a.tags).filter(t => t).map(tag => tag.split(".")[0]).join(":") })) @@ -73,7 +73,7 @@ async function desambiguate(analysis) { .join("\n"); - const response = await (CONCRAFT_MODE === 'local' ? runConcraftLocally : invokeConcraftRemotely)(input); + const response = await (CONCRAFT_MODE === 'local' ? runConcraftLocally : invokeConcraftRemotely)(input, ...args); const keys = ["start", "end", "segment", "lemma", "tags", "frequency", "qualifiers", "prob", "interp_meta", "eos", "seg_meta", "disamb"]; const output = []; @@ -99,9 +99,9 @@ async function desambiguate(analysis) { return output; } -async function danalyse(input) { - const analysis = await analyse(input); - return await desambiguate(analysis); +async function danalyse(input, morfeuszArgs, concraftArgs) { + const analysis = await analyse(input, morfeuszArgs); + return await desambiguate(analysis, concraftArgs); } function generate(input, ...tags) { @@ -197,4 +197,4 @@ async function main([ interpreter, script, action, ...args ]) { } -main(process.argv); +main(process.argv); \ No newline at end of file