Software Projects

Building an Apertium Standalone Language Pair Translation Jar Package for Android on Ubuntu

Posted in Uncategorized by rmt on June 16, 2013

This is a procedure for creating standalone packages that can be bundled with Android apps for supporting in-app language translation while offline–that is, without a cellular or wifi data connection.

Requires: Android SDK

Install required packages:
sudo apt-get install subversion libxml2-dev xsltproc flex libpcre3-dev gawk libxml2-utils

Get Apertium repository code:
svn co http://svn.code.sf.net/p/apertium/svn/ apertium

Compile and install lttoolbox:
cd apertium/trunk/lttoolbox
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./autogen.sh
make
sudo make install
sudo ldconfig

Compile and install apertium:
cd ../apertium
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./autogen.sh
make
sudo make install
sudo ldconfig

Compile and install lttoolbox-java:
cd ../lttoolbox-java
sh autogen.sh
make
sudo make install

Compile a language pair (for example, English-Spanish):
(Android-related note: If you see ‘you don’t have cg-proc installed’ then this pair requires the constraint grammar
package, so this pair is not Android compatible.)
cd ../apertium-en-es
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./autogen.sh
make
sudo make install
echo 'test' | apertium en-es

Create a symbolic link in the former location of Android’s ‘dx’:
cd /home/$USER/android-sdk-linux/platform-tools
ln -s ../build-tools/17.0.0/dx dx

Compile the standalone package for a language pair (for example, English-Spanish):
cd apertium/trunk/lttoolbox-java
export LTTOOLBOX_JAVA_PATH='/usr/local/share/apertium/lttoolbox.jar'
export ANDROID_SDK_PATH='/home/$USER/android-sdk-linux'
./apertium-pack-j /usr/local/share/apertium/modes/en-es.mode /usr/local/share/apertium/modes/es-en.mode

At this point apertium-en-es.jar has been created in apertium/trunk/lttoolbox-java.

REFERENCES

Install language pairs: http://wiki.apertium.org/wiki/Apertium_on_Ubuntu
Build standalone language pair packages: http://wiki.apertium.org/wiki/Language_pair_packages

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s