Difference between revisions of "Apertium-apy/Debian"
(wget -> curl) |
|||
(16 intermediate revisions by 4 users not shown) | |||
Line 6: | Line 6: | ||
* you can run Apertium within your super-fortified network without your highly confidential translations touching anyone else's computer |
* you can run Apertium within your super-fortified network without your highly confidential translations touching anyone else's computer |
||
* you don't have to worry about anyone else's API server going down right when you need it the most |
* you don't have to worry about anyone else's API server going down right when you need it the most |
||
* you have control over how many concurrent apertium processes you run (if your site or program calls plain `apertium` on each request, you can easily overload your server) |
|||
{{TOCD}} |
{{TOCD}} |
||
==Quickstart== |
==Quickstart== |
||
Unless you're running Debian sid, you'll need the apt-repo: |
|||
Install prerequisites: |
|||
<pre> |
<pre> |
||
curl -sS https://apertium.projectjj.com/apt/install-nightly.sh | sudo bash |
|||
sudo bash install-nightly.sh |
|||
sudo apt-get -f install apertium-all-dev build-essential subversion python3-dev python3-pip zlib1g-dev |
|||
sudo pip3 install --upgrade tornado |
|||
</pre> |
</pre> |
||
⚫ | |||
⚫ | |||
<pre> |
<pre> |
||
sudo apt-get install apertium-apy |
|||
sudo apt-get install apertium-eng-kaz apertium-sme-nob apertium-hbs-mkd apertium-eo-en apertium-tat-rus # etc. |
sudo apt-get install apertium-eng-kaz apertium-sme-nob apertium-hbs-mkd apertium-eo-en apertium-tat-rus # etc. |
||
</pre> |
</pre> |
||
(Here we're assuming you only want packaged pairs, see [[Installation]] on how to install |
(Here we're assuming you only want packaged pairs, see [[Installation]] on how to install pairs that are only in SVN.) |
||
Now check out and run APY: |
|||
You can now start APY like this: |
|||
<pre> |
<pre> |
||
sudo systemctl start apertium-apy |
|||
svn co https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy |
|||
cd apertium-apy |
|||
### This will start the APY server: |
|||
./servlet.py /usr/share/apertium # This is the path to package-installed Apertium language pairs |
|||
</pre> |
</pre> |
||
It should look like |
|||
and enable it for starting after a reboot like this: |
|||
[[Image:apy-startup.png]] |
|||
<pre> |
|||
sudo systemctl enable apertium-apy |
|||
</pre> |
|||
==Test that it works== |
|||
You can do |
|||
<pre> |
|||
sudo systemctl status apertium-apy |
|||
</pre> |
|||
and it should show something like |
|||
<pre> |
|||
● apertium-apy.service - Apertium APY service |
|||
Loaded: loaded (/lib/systemd/system/apertium-apy.service; disabled; vendor preset: enabled) |
|||
Active: active (running) since må. 2016-06-13 11:38:10 CEST; 3s ago |
|||
Docs: http://wiki.apertium.org/wiki/Apertium-apy |
|||
Main PID: 14813 (python3) |
|||
CGroup: /system.slice/apertium-apy.service |
|||
└─14813 /usr/bin/python3 servlet.py /usr/share/apertium/modes |
|||
juni 13 11:38:10 gamlepadda systemd[1]: Started Apertium APY service. |
|||
juni 13 11:38:11 gamlepadda python3[14813]: [W 160613 11:38:11 servlet:865] Unable to import CLD2, continuing using naive method of lang |
|||
juni 13 11:38:11 gamlepadda python3[14813]: [I 160613 11:38:11 servlet:792] 7 pair modes found |
|||
juni 13 11:38:11 gamlepadda python3[14813]: [I 160613 11:38:11 servlet:792] 0 analyzer modes found |
|||
juni 13 11:38:11 gamlepadda python3[14813]: [I 160613 11:38:11 servlet:792] 0 generator modes found |
|||
juni 13 11:38:11 gamlepadda python3[14813]: [I 160613 11:38:11 servlet:792] 0 tagger modes found |
|||
juni 13 11:38:11 gamlepadda python3[14813]: [I 160613 11:38:11 servlet:898] Serving at http://localhost:2737 |
|||
</pre> |
|||
if it's started. (Press q to get your terminal back if it put you in less-mode.) |
|||
Try checking what language data it found: |
|||
Open a new terminal to check that it's OK: |
|||
<pre> |
<pre> |
||
curl http://localhost:2737/listPairs |
curl http://localhost:2737/listPairs |
||
Line 42: | Line 67: | ||
It should contain a list of pairs. |
It should contain a list of pairs. |
||
Say the list contains <code>{"sourceLanguage": "sme", "targetLanguage": "nob"}</code>, then we can try translating the sentence "in leat doppe" from sme to nob: |
Say the list contains <code>{"sourceLanguage": "sme", "targetLanguage": "nob"}</code>, then we can try translating the sentence "in leat doppe" from sme to nob: |
||
Line 51: | Line 77: | ||
If everything worked, congrats, you have your own Apertium API server running! |
If everything worked, congrats, you have your own Apertium API server running! |
||
Now open port 2737 in your firewall and point your [[apertium-html-tools|website]] or [[Android|app]] at it :-) |
|||
If you ran into trouble, please ask for help on [[IRC]] or the [[Contact|mailing list]]. |
If you ran into trouble, please ask for help on [[IRC]] or the [[Contact|mailing list]]. |
||
==If you don't have/want root== |
|||
==Run on init== |
|||
See [[Apertium-apy#Running_as_a_--user_unit]]. |
|||
There are example init scripts in <code>apertium-apy/tools/{systemd,upstart,sysvinit}</code>; if you're running a fairly recent Ubuntu (15.04 or newer) or Debian (jessie or newer), then you should follow the instructions from <code>[https://svn.code.sf.net/p/apertium/svn/trunk/apertium-tools/apertium-apy/tools/systemd/README apertium-apy/tools/systemd/README]</code>. |
|||
==Troubleshooting== |
|||
===<code>servlet.py: error: APY needs a UTF-8 locale, please set LANG or LC_ALL</code>=== |
|||
You need to have at least one UTF-8 locale installed. Do |
|||
<pre>locale -a</pre> |
|||
to see which ones you have installed. At minimum, Debian/Ubuntu derivatives will have the <code>C.UTF-8</code> locale available, which will do. But you can use any UTF-8 locale you want, such as <code>en_US.utf8</code> or <code>pt_BR.utf8</code>. To edit daemon locale, run |
|||
<pre>sudo systemctl edit apertium-apy</pre> |
|||
which will open an empty file for you; enter |
|||
<pre>[Service] |
|||
Environment=LC_ALL=C.UTF-8</pre> |
|||
there and verify what it all looks like with |
|||
<pre>systemctl cat apertium-apy</pre> |
|||
then try starting again with |
|||
<pre>sudo systemctl start apertium-apy</pre> |
|||
==More info== |
==More info== |
||
Line 63: | Line 106: | ||
[[Category:Tools]] |
[[Category:Tools]] |
||
[[Category:Installation]] |
[[Category:Installation]] |
||
[[Category:Documentation in English]] |
|||
[[Category:Quickstart]] |
Latest revision as of 21:00, 2 April 2021
This is a quickstart guide to setting up your very own Apertium API server on Debian-based systems (including Ubuntu).
Why?[edit]
Running your own API server means
- you get to decide what kinds of crazy half-finished language pairs to serve (or you can just serve a few of the high-quality ones that you like)
- you can run Apertium within your super-fortified network without your highly confidential translations touching anyone else's computer
- you don't have to worry about anyone else's API server going down right when you need it the most
- you have control over how many concurrent apertium processes you run (if your site or program calls plain `apertium` on each request, you can easily overload your server)
Quickstart[edit]
Unless you're running Debian sid, you'll need the apt-repo:
curl -sS https://apertium.projectjj.com/apt/install-nightly.sh | sudo bash
Now install APY and the language pairs you want:
sudo apt-get install apertium-apy sudo apt-get install apertium-eng-kaz apertium-sme-nob apertium-hbs-mkd apertium-eo-en apertium-tat-rus # etc.
(Here we're assuming you only want packaged pairs, see Installation on how to install pairs that are only in SVN.)
You can now start APY like this:
sudo systemctl start apertium-apy
and enable it for starting after a reboot like this:
sudo systemctl enable apertium-apy
Test that it works[edit]
You can do
sudo systemctl status apertium-apy
and it should show something like
● apertium-apy.service - Apertium APY service Loaded: loaded (/lib/systemd/system/apertium-apy.service; disabled; vendor preset: enabled) Active: active (running) since må. 2016-06-13 11:38:10 CEST; 3s ago Docs: http://wiki.apertium.org/wiki/Apertium-apy Main PID: 14813 (python3) CGroup: /system.slice/apertium-apy.service └─14813 /usr/bin/python3 servlet.py /usr/share/apertium/modes juni 13 11:38:10 gamlepadda systemd[1]: Started Apertium APY service. juni 13 11:38:11 gamlepadda python3[14813]: [W 160613 11:38:11 servlet:865] Unable to import CLD2, continuing using naive method of lang juni 13 11:38:11 gamlepadda python3[14813]: [I 160613 11:38:11 servlet:792] 7 pair modes found juni 13 11:38:11 gamlepadda python3[14813]: [I 160613 11:38:11 servlet:792] 0 analyzer modes found juni 13 11:38:11 gamlepadda python3[14813]: [I 160613 11:38:11 servlet:792] 0 generator modes found juni 13 11:38:11 gamlepadda python3[14813]: [I 160613 11:38:11 servlet:792] 0 tagger modes found juni 13 11:38:11 gamlepadda python3[14813]: [I 160613 11:38:11 servlet:898] Serving at http://localhost:2737
if it's started. (Press q to get your terminal back if it put you in less-mode.)
Try checking what language data it found:
curl http://localhost:2737/listPairs
It should contain a list of pairs.
Say the list contains {"sourceLanguage": "sme", "targetLanguage": "nob"}
, then we can try translating the sentence "in leat doppe" from sme to nob:
curl 'http://localhost:2737/translate?langpair=sme|nob&q=in+leat+doppe'
That should give something like {"responseData": {"translatedText": "jeg er ikke der borte"}, "responseDetails": null, "responseStatus": 200}
.
If everything worked, congrats, you have your own Apertium API server running!
Now open port 2737 in your firewall and point your website or app at it :-)
If you ran into trouble, please ask for help on IRC or the mailing list.
If you don't have/want root[edit]
See Apertium-apy#Running_as_a_--user_unit.
Troubleshooting[edit]
servlet.py: error: APY needs a UTF-8 locale, please set LANG or LC_ALL
[edit]
You need to have at least one UTF-8 locale installed. Do
locale -a
to see which ones you have installed. At minimum, Debian/Ubuntu derivatives will have the C.UTF-8
locale available, which will do. But you can use any UTF-8 locale you want, such as en_US.utf8
or pt_BR.utf8
. To edit daemon locale, run
sudo systemctl edit apertium-apy
which will open an empty file for you; enter
[Service] Environment=LC_ALL=C.UTF-8
there and verify what it all looks like with
systemctl cat apertium-apy
then try starting again with
sudo systemctl start apertium-apy
More info[edit]
See Apertium-apy for other things you can do with Apy and more documentation.