apertium / organisation

Second point of contact for all things Apertium
https://apertium.org/
19 stars 6 forks source link

Simple Apertium-as-Service idea - Helplessly lost #34

Open SomeTroglodyte opened 1 year ago

SomeTroglodyte commented 1 year ago

This works (kotlin):

    fun String.apertiumTranslated(): String {
        val charset = Charset.forName("UTF-8")
        val process = Runtime.getRuntime().exec("apertium en-eo")
        val stdin = process.outputStream
        stdin.write(this.toByteArray(charset))
        stdin.flush()
        stdin.close()
        process.waitFor()
        return process.inputStream.readBytes().toString(charset)
    }

Question: Replace function body so the translation runs entirely in-process.

Sounds trivial. I spent 30 minutes getting a large FOSS game to run just fine in a natively unsupported language - translated on-the-fly through Apertium, then hours researching that question. I even cloned caffeine in the hopes reading source might be clearer. I give up. The only path that's documented and contains no "legacy" or "sourceforge" dead-ends wouldn't satisfy the "in-process" wish.

I'm not looking for a ready-cooked solution. I just want to raise awareness that your jungle can be extremely confusing for outsiders.

TinoDidriksen commented 1 year ago

Kotlin, so Java. We do not have up-to-date Java tools, and we have no plans on continuing the Java codebase.

If you were doing this in native code or Python, then you could get it all in-process. Still not trivially, but certainly doable. I actually recommend instrumenting a sub-process, as that insulates the host from pipe crashes.

Also, we have Apertium-as-a-Service: https://github.com/apertium/apertium-apy

SomeTroglodyte commented 1 year ago

Thanks. It is as I guessed. Goal reached - awareness that someone could come from this direction. Keep it up :+1: