apertium / apertium-apy

📦 Apertium HTTP Server in Python
https://wiki.apertium.org/wiki/Apertium-apy
GNU General Public License v3.0
32 stars 42 forks source link

cannot translate #87

Closed scejja closed 6 years ago

scejja commented 6 years ago

I'm new to apertium-apy. I install this way in ubuntu server xenial (just for english and spanish):

wget http://apertium.projectjj.com/apt/install-nightly.sh sudo bash install-nightly.sh sudo apt-get install apertium-apy sudo apt-get install apertium-en-es sudo systemctl start apertium-apy.service sudo systemctl enable apertium-apy.service

The service is running, and with this curl http://localhost:2737/listPairs I get {"responseStatus": 200, "responseDetails": null, "responseData": [{"targetLanguage": "eng_US", "sourceLanguage": "spa"}, {"targetLanguage": "eng", "sourceLanguage": "spa"}, {"targetLanguage": "spa", "sourceLanguage": "eng"}]}

But I cannot translate anything, for example, curl 'http://localhost:2737/translate?langpair=eng|spa&q=this+is+a+test' {"message": "Internal Server Error", "status": "error", "explanation": "Internal Server Error", "code": 500}

What I'm doing wrong? I'm trying to use in combination with ContentTranslation mediawiki extension, and I need to be sure that it works from command line. Thanks in advance

sushain97 commented 6 years ago

What do the APy logs say? I can't help with only the endpoint error details :\

scejja commented 6 years ago

sudo cat /etc/logrotate.d/apertium-apy

/var/log/apertium/apertium-apy.log { daily copytruncate missingok compress notifempty rotate 15 size 256M }

File /var/log/apertium/apertium-apy.log does not even exist.

I have seen that this queries have an empty response ({}). Maybe I have to install something more. curl 'http://localhost:2737/list?q=analyzers' curl 'http://localhost:2737/list?q=generators' curl 'http://localhost:2737/list?q=taggers'

Service status: ● apertium-apy.service - Translation server and API for Apertium Loaded: loaded (/lib/systemd/system/apertium-apy.service; enabled; vendor preset: enabled) Active: active (running) since dom 2018-03-11 12:55:57 CET; 10s ago Docs: http://wiki.apertium.org/wiki/Apertium-apy Main PID: 2289 (python3) Tasks: 1 Memory: 18.7M CPU: 415ms CGroup: /system.slice/apertium-apy.service └─2289 /usr/bin/python3 servlet.py /usr/share/apertium/modes

mar 11 12:55:59 pc python3[2289]: [W 180311 12:55:59 servlet:1466] Unable to import CLD2, continuing using naive method of language detection mar 11 12:55:59 pc python3[2289]: [I 180311 12:55:59 servlet:1316] 3 pair modes found mar 11 12:55:59 pc python3[2289]: [I 180311 12:55:59 servlet:1316] 0 tokenise modes found mar 11 12:55:59 pc python3[2289]: [I 180311 12:55:59 servlet:1316] 0 generator modes found mar 11 12:55:59 pc python3[2289]: [I 180311 12:55:59 servlet:1316] 0 spell modes found mar 11 12:55:59 pc python3[2289]: [I 180311 12:55:59 servlet:1316] 0 tagger modes found mar 11 12:55:59 pc python3[2289]: [I 180311 12:55:59 servlet:1316] 0 analyzer modes found mar 11 12:55:59 pc python3[2289]: [I 180311 12:55:59 servlet:1528] Serving at http://localhost:2737 mar 11 12:55:59 pc python3[2289]: [I 180311 12:55:59 servlet:1540] Initialised systemd watchdog, pinging every 5000.0s mar 11 12:56:03 pc python3[2289]: [I 180311 12:56:03 web:1908] 200 GET /list?q=taggers (::1) 0.95ms

More tests:

curl 'http://localhost:2737/translate?langpair=eng|spa&q=This does not work' curl: (52) Empty reply from server

curl 'http://localhost:2737/translate?langpair=eng|spa&q=This' {"explanation": "Internal Server Error", "code": 500, "status": "error", "message": "Internal Server Error"}

unhammer commented 6 years ago

sudo journalctl -fu apertium-apy should give the apy output.

You could also test that the language pairs work from the command line, e.g. echo yo | apertium es-en

scejja commented 6 years ago

$ sudo journalctl -fu apertium-apy

-- Logs begin at lun 2018-03-12 00:02:35 CET. -- mar 12 00:06:19 pc python3[1377]: File "/usr/share/apertium-apy/translation.py", line 116, in startPipeline mar 12 00:06:19 pc python3[1377]: stdout=out_from)) mar 12 00:06:19 pc python3[1377]: File "/usr/lib/python3/dist-packages/tornado/process.py", line 233, in init mar 12 00:06:19 pc python3[1377]: self.proc = subprocess.Popen(*args, **kwargs) mar 12 00:06:19 pc python3[1377]: File "/usr/lib/python3.5/subprocess.py", line 947, in init mar 12 00:06:19 pc python3[1377]: restore_signals, start_new_session) mar 12 00:06:19 pc python3[1377]: File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child mar 12 00:06:19 pc python3[1377]: raise child_exception_type(errno_num, err_msg) mar 12 00:06:19 pc python3[1377]: FileNotFoundError: [Errno 2] No such file or directory: 'lrx-proc' mar 12 00:06:19 pc python3[1377]: [E 180312 00:06:19 web:1908] 500 GET /translate?langpair=eng|spa&q=This (::1) 3188.94ms

echo yo | apertium es-en /usr/share/apertium/modes/es-en.mode: 3: /usr/share/apertium/modes/es-en.mode: lrx-proc: not found

I don't know what is lrx-proc and why it is not installed. I only used this guide: http://wiki.apertium.org/wiki/Apertium-apy/Debian

unhammer commented 6 years ago

sudo apt-get install apertium-en-es should have installed lrx-proc, but apparantly didn't, that's a packaging error.

This should be possible to fix with sudo apt install apertium-lex-tools.

scejja commented 6 years ago

It is working now and mediawiki ContentTranslation extension too. Thaks a lot for your help!!