Difference between revisions of "Apertium-service"

From Apertium
Jump to navigation Jump to search
(No difference)

Revision as of 02:03, 22 November 2009

Compiling and Installing

This document covers compilation and installation of apertium-service on Unix and Unix-like systems only, but it can be compiled also on other systems that meet the requirements.

apertium-service, like many other Open Source projects, uses GNU buildtools (like autoconf and automake) to create a build environment.


Requirements

You need the following software installed:

  • liblttoolbox3 - library for lttoolbox, a toolbox for lexical processing, morphological analysis and generation of words.
  • libapertium3 - library for apertium, a Free / Open-Source machine translation system.
  • libtextcat0 - a library implementing the classification technique described in Cavnar & Trenkle, "N-Gram-Based Text Categorization". (optional)
  • libxmlrpc-c3 - a lightweight RPC library based on XML and HTTP for C and C++. (>= 1.16.07-1)
  • libxml++2 - a C++ interface to libxml2, the GNOME XML library.
  • libboost - Boost C++ libraries are a collection of peer-reviewed, Open Source libraries that extend the functionality of C++.


In particular, the following components from Boost C++ libraries are required:

  • libboost-thread - for portable C++ multi-threading.
  • libboost-filesystem - for portable filesystem operations in C++.
  • libboost-date-time - for portable date/time operations in C++.
  • libboost-regex - regular expression library for C++.
  • libboost-program-options - program options library for C++.

Download

apertium-service can be downloaded from the Apertium SVN repository with the following command:

$ svn co http://apertium.svn.sourceforge.net/svnroot/apertium/trunk/apertium-service


Configuring the source tree

The next step is to configure the apertium-service source tree for your particular platform and personal requirements. This is done using the script configure included in the root directory of the distribution. (Developers downloading an unreleased version of the apertium-service source tree will need to have autoconf and libtool installed and will need to run the script autogen.sh before proceeding with the next steps. This is not necessary for official releases.)

To configure the source tree using all the default options, simply type ./configure. To change the default options, configure accepts a variety of variables and command line options.

The most important option is the location --prefix where the apertium-service is to be installed later, because apertium-service has to be configured for this location to work correctly. More fine-tuned control of the location of files is possible with additional configure options.

In addition, it is sometimes necessary to provide the configure script with extra information about the location of your compiler, libraries, or header files. This is done by passing either environment variables or command line options to configure. For more information, see the configure manual page.

For a short impression of what possibilities you have, here is a typical example which compiles apertium-service for the installation tree /sw/pkg/apertium-service with a particular compiler and flags:

$ CC="pgcc" CFLAGS="-O2" \
./configure --prefix=/sw/pkg/apertium-service

When configure is run it will take a few seconds to test for the availability of features on your system and build Makefiles which will later be used to compile the server.

Details on all the different configure options are available on the configure manual page.


Build

Now you can build the various parts which form the apertium-service package by simply running the command:

$ make

A base configuration takes a few minutes to compile and the time will vary widely depending on your hardware.


Install

Now it's time to install the package under the configured installation PREFIX (see --prefix option above) by running:

$ make install


Customise

Next, you can customise your apertium-service by editing the configuration files under PREFIX/etc/apertium-service/.

$ vi PREFIX/etc/apertium-service/configuration.xml

Test

Now you can start your apertium-service by immediately running:

$ PREFIX/bin/apertium-service

and then you should be able to make your first XML-RPC query via URL http://localhost:port/.

For example, the following python script:

$ cat test.py

#!/usr/bin/python
# coding=utf-8
# -*- encoding: utf-8 -*-

import xmlrpclib;

proxy = xmlrpclib.ServerProxy("http://localhost:6173/RPC2");
res = proxy.translate("Això no és una prova.", "ca", "en");
print res["translation"];

Should give the output,

$ python test.py 
This is not a test.

Providing you have the ca-en pair installed. You can find which language pairs are detected with the method languagePairs(), for example,

proxy = xmlrpclib.ServerProxy("http://localhost:6173/RPC2");

for pair in proxy.languagePairs(): #{
        sys.stdout.write(pair["srcLang"] + "-" + pair["destLang"] + " ");
#}
print "";