Aperture translator. Is there any way to get the original phrase

Is there a way in the aperture translator to get the source phrase for the translation?

those. get something like:

phrase: {
  original: { Hola, buenos días},
  translated: {Hello, good morning}
}

I need this to create a mechanism to improve translations.

+4
source share
1 answer

If you send the chassis via the command line interface, for example

xzcat corpus.sme.xz | sed 's/$/ ./' | apertium -f html-noent sme-nob > translated.nob.mt

then you can try just

xzcat corpus.sme.xz | paste - translated.nob.mt

to get input near the exit. This suggests that you want to share things on the news. sedexists so that words do not move along newline characters (rules, as a rule, do not move along the boundaries of sentences).

It will be fast, but it is a bit hacky and there are many cases with edges.


, JSON API .

Debian/Ubuntu ( apertium repos), API

sudo apt install apertium-apy
sudo systemctl start apertium-apy   # start it right now
sudo systemctl enable apertium-apy  # let it start on next boot

:

$ echo 'Jeg liker ikke ansjos' | curl --data-urlencode 'q@-' 'localhost:2737/translate?langpair=nob|nno'
{"responseDetails": null, "responseData": {"translatedText": "Eg likar ikkje ansjos"}, "responseStatus": 200}

( Javascript ajax, http://wiki.apertium.org/wiki/Apertium-apy/Debian http://wiki.apertium.org/wiki/Apertium-apy#Usage)

, apertium-apy , /usr/share/apertium/modes; ( systemctl), .


JSON, , jq (sudo apt install jq), .

$ orig="Jeg liker ikke ansjos"
$ echo "$orig" \
  | curl -Ss --data-urlencode 'q@-' 'localhost:2737/translate?langpair=nob|nno' \
  | jq "{phrase: {original:\"$orig\", translated:.responseData.translatedText }}"
{
  "phrase": {
    "original": "Jeg liker ikke ansjos",
    "translated": "Eg likar ikkje ansjos"
  }
}

:

xzcat corpus.nob.xz | while read -r orig; do 
  echo "$orig" \
    | curl -Ss --data-urlencode 'q@-' 'localhost:2737/translate?langpair=nob|nno' \
    | jq "{phrase: {original:\"$orig\", translated:.responseData.translatedText}}";
done

( 500 , 23,7 , paste - 5.5 .)

+4

Source: https://habr.com/ru/post/1689641/


All Articles