Difference between revisions of "Apertium-apy/Debian"

From Apertium
Jump to navigation Jump to search
Line 13: Line 13:
 
==Quickstart==
 
==Quickstart==
   
Install prerequisites:
+
Install apt-repo and APY:
 
<pre>
 
<pre>
 
wget http://apertium.projectjj.com/apt/install-nightly.sh
 
wget http://apertium.projectjj.com/apt/install-nightly.sh
 
sudo bash install-nightly.sh
 
sudo bash install-nightly.sh
sudo apt-get -f install apertium-all-dev build-essential subversion python3-dev python3-pip zlib1g-dev
+
sudo apt-get install apertium-apy
sudo pip3 install --upgrade tornado
 
 
</pre>
 
</pre>
   
Line 27: Line 26:
 
(Here we're assuming you only want packaged pairs, see [[Installation]] on how to install SVN pairs.)
 
(Here we're assuming you only want packaged pairs, see [[Installation]] on how to install SVN pairs.)
   
Now check out and run APY:
+
Now try starting APY and checking its status:
 
<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
 
  +
sudo systemctl status 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
 
It should look like
   
 
[[Image:apy-startup.png]]
 
[[Image:apy-startup.png]]
  +
  +
Press q to get your terminal back.
   
 
=== Testing it out ===
 
=== Testing it out ===
Line 54: Line 54:
   
   
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 everything worked, congrats, you have your own Apertium API server running! You can enable it on startup with
  +
<pre>
  +
sudo systemctl enable apertium-apy
  +
</pre>
  +
  +
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]].

Revision as of 09:40, 13 June 2016

This is a quickstart guide to setting up your very own Apertium API server on Debian-based systems (including Ubuntu).

Why?

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

Install apt-repo and APY:

wget http://apertium.projectjj.com/apt/install-nightly.sh
sudo bash install-nightly.sh
sudo apt-get install apertium-apy

And install the language pairs you want:

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 SVN pairs.)

Now try starting APY and checking its status:

sudo systemctl start apertium-apy

sudo systemctl status apertium-apy

It should look like

Apy-startup.png

Press q to get your terminal back.

Testing it out

Open a new terminal to check that it's OK:

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! You can enable it on startup with

sudo systemctl enable apertium-apy

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.

Run on init

There are example init scripts in apertium-apy/tools/{systemd,upstart,sysvinit}; if you're running a fairly recent Ubuntu (15.04 or newer) or Debian (jessie or newer), then you should follow the instructions from apertium-apy/tools/systemd/README.

More info

See Apertium-apy for other things you can do with Apy and more documentation.