Translate without disambiguation

From Apertium
Revision as of 21:05, 2 April 2021 by Tino Didriksen (talk | contribs) (wget -> curl)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Prerequisites:

curl -sS https://apertium.projectjj.com/apt/install-nightly.sh | sudo bash
sudo apt install python3-streamparser apertium-eng-ita
$ echo "fruit flies like a banana" | lt-proc -w '/usr/share/apertium/apertium-eng-ita/eng-ita.automorf.bin' | python3 -c $'import streamparser,sys\nfor (b, lu) in streamparser.parse_file(sys.stdin,with_text=True):\n  print(b+"[/]".join(["^"+streamparser.reading_to_string(r)+"$" for r in lu.readings]),end="")' | apertium-pretransfer| lt-proc -b '/usr/share/apertium/apertium-eng-ita/eng-ita.autobil.bin' | python3 -c $'import streamparser,sys\nfor (b, lu) in streamparser.parse_file(sys.stdin, with_text=True):\n  print(b + "[/]".join(["^"+lu.wordform+"/"+streamparser.reading_to_string(r)+"$" for r in lu.readings]), end="")' | apertium-transfer -b '/usr/share/apertium/apertium-eng-ita/apertium-eng-ita.eng-ita.t1x'  '/usr/share/apertium/apertium-eng-ita/eng-ita.t1x.bin' | apertium-interchunk '/usr/share/apertium/apertium-eng-ita/apertium-eng-ita.eng-ita.t2x'  '/usr/share/apertium/apertium-eng-ita/eng-ita.t2x.bin' | apertium-postchunk '/usr/share/apertium/apertium-eng-ita/apertium-eng-ita.eng-ita.t3x'  '/usr/share/apertium/apertium-eng-ita/eng-ita.t3x.bin' | lt-proc -g '/usr/share/apertium/apertium-eng-ita/eng-ita.autogen.bin' | lt-proc -p '/usr/share/apertium/apertium-eng-ita/eng-ita.autopgen.bin'

gives

Mosche di frutta[/]#volare come piacere[/][/]piace[/]#piacere una banana[/]di banano 

That was one long pipeline. Put this bit in a file:

lt-proc -w '/usr/share/apertium/apertium-eng-ita/eng-ita.automorf.bin' | python3 -c $'import streamparser,sys\nfor (b, lu) in streamparser.parse_file(sys.stdin,with_text=True):\n  print(b+"[/]".join(["^"+streamparser.reading_to_string(r)+"$" for r in lu.readings]),end="")' | apertium-pretransfer| lt-proc -b '/usr/share/apertium/apertium-eng-ita/eng-ita.autobil.bin' | python3 -c $'import streamparser,sys\nfor (b, lu) in streamparser.parse_file(sys.stdin, with_text=True):\n  print(b + "[/]".join(["^"+lu.wordform+"/"+streamparser.reading_to_string(r)+"$" for r in lu.readings]), end="")' | apertium-transfer -b '/usr/share/apertium/apertium-eng-ita/apertium-eng-ita.eng-ita.t1x'  '/usr/share/apertium/apertium-eng-ita/eng-ita.t1x.bin' | apertium-interchunk '/usr/share/apertium/apertium-eng-ita/apertium-eng-ita.eng-ita.t2x'  '/usr/share/apertium/apertium-eng-ita/eng-ita.t2x.bin' | apertium-postchunk '/usr/share/apertium/apertium-eng-ita/apertium-eng-ita.eng-ita.t3x'  '/usr/share/apertium/apertium-eng-ita/eng-ita.t3x.bin' | lt-proc -g '/usr/share/apertium/apertium-eng-ita/eng-ita.autogen.bin' | lt-proc -p '/usr/share/apertium/apertium-eng-ita/eng-ita.autopgen.bin'

call it "eng-ita_ambig.mode" and chmod +x it. Now you can

$ echo "fruit flies like a banana" | ./eng-ita_ambig.mode