Difference between revisions of "Become a language pair developer for Apertium"

From Apertium
Jump to navigation Jump to search
Line 1: Line 1:
{{TOCD}}This is a 3-part, step-by-step guide on how to use a development version of Apertium to make a change in a language pair. These instructions assume that you are using Ubuntu or Debian; if not then please see the [[Installation]] page for instructions for other OS's such as Mac OS X or Windows.
{{TOCD}}This is a 3-part, step-by-step guide on how to use a development version of Apertium to make a change in a language pair. These instructions assume that you are using [http://wiki.apertium.org/wiki/Apertium_on_Ubuntu Ubuntu or Debian]; if not then please see the [[Installation]] page for installation on other OS's such as on [http://wiki.apertium.org/wiki/Apertium_on_Mac_OS_X Mac OS X local] and [http://wiki.apertium.org/wiki/Apertium_on_Mac_OS_X_(System) systemwide ] or [http://wiki.apertium.org/wiki/Apertium_on_Windows Windows] .


== Introduction ==
== Introduction ==
Line 13: Line 13:
==== Step 1: Get the Prerequisites ====
==== Step 1: Get the Prerequisites ====


A development version of Apertium and the language pair you want to change has to be installed on your computer first before you can change something about the language pair.
A development version of Apertium and the language pair you want to change has to be installed on your computer first before you can change something about the language pair. If you're looking at installing on a different distribution of Linux than Ubuntu you can find instructions here on the wiki for [[Apertium on Arch Linux]], [[Apertium on Fedora]], and [[Apertium on openSUSE]]. There is currently no method for installing on Mandriva.


Start by opening a new terminal.
Start by opening a new terminal.
Line 60: Line 60:


''Note: You can find a full list of modules at [https://apertium.svn.sourceforge.net/svnroot/apertium/trunk/ https://apertium.svn.sourceforge.net/svnroot/apertium/trunk/].''
''Note: You can find a full list of modules at [https://apertium.svn.sourceforge.net/svnroot/apertium/trunk/ https://apertium.svn.sourceforge.net/svnroot/apertium/trunk/].''

Normally, Apertium is installed under the directory <code>/usr/local</code>. However, if you want it installed elsewhere or don't want to install it as root, enter:
<pre>
PREFIX=/path/to/where/I/want/Apertium
PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
export PKG_CONFIG_PATH
</pre>

Then, in the lttoolbox and apertium directories, do:
<pre>
./autogen.sh --prefix=$PREFIX
make
make install
ldconfig
</pre>

'''Warning:''' If you didn't specify <code>$PREFIX</code> or don't know what this means then enter:

<pre>
./autogen.sh
make
make install
ldconfig
</pre>

(If you didn't specify a prefix, use <code>sudo</code> before the last two commands.)

Then, in the directory apertium-eo-en, enter:
<pre>
./autogen.sh --prefix=$PREFIX
make
make install
</pre>

(Use <code>sudo</code> before the last command if you didn't specify a prefix.)


==== Final Step: Compilation & Installation ====
==== Final Step: Compilation & Installation ====
Line 89: Line 124:
sudo make install
sudo make install
</pre>
</pre>
,for your language pair which replaces the text <modulename>.
for your language pair which replaces the text <modulename>.


For further instruction, if necessary, see [[Apertium on Ubuntu]].
For further instruction, if necessary, see [[Apertium on Ubuntu]].

Revision as of 22:50, 21 December 2011

This is a 3-part, step-by-step guide on how to use a development version of Apertium to make a change in a language pair. These instructions assume that you are using Ubuntu or Debian; if not then please see the Installation page for installation on other OS's such as on Mac OS X local and systemwide or Windows .

Introduction

There are 2 options as to how you can get Apertium. You can use either the terminal to get the most up-to-date versions or the Synaptic package manager can be used to get development versions that aren't quite as up-to-date. There are pros and cons to each, however, the terminal method is more for those that intend to submit their work while using the package manager is normally easier and you are using a graphical interface instead of a command line.

You don't need to know a programming language to develop for Apertium. All development for adding new words is done with a text or xml editor.

Getting Ready

Method 1: TERMINAL

Step 1: Get the Prerequisites

A development version of Apertium and the language pair you want to change has to be installed on your computer first before you can change something about the language pair. If you're looking at installing on a different distribution of Linux than Ubuntu you can find instructions here on the wiki for Apertium on Arch Linux, Apertium on Fedora, and Apertium on openSUSE. There is currently no method for installing on Mandriva.

Start by opening a new terminal.

Then, use this command to install the prerequisites:

sudo apt-get install subversion build-essential g++ pkg-config gawk libxml2 \
> libxml2-dev libxml2-utils xsltproc flex automake autoconf libtool libpcre3-dev

The terminal will then ask you for your password to begin.

Note: Keep track of how you type your password in your head. The terminal will not display characters entered for your password for security reasons.

After you have entered your password, press the "Enter" key and wait for your computer to download and install the packages.

Step 2: Get Apertium, lttoolbox, & Your Language Pair(s)

Using the same terminal, you can download the entire language pairs tree from SVN using the command:

svn co https://apertium.svn.sourceforge.net/svnroot/apertium

Keep in mind that the full tree is over 4GB. If you have a slow connection, limited disk space, or a limited data transfer amount, installing the whole tree is not recommended. However, if you want to focus on a small number of language pairs you can easily download and add language pairs with a command such as:

svn co https://apertium.svn.sourceforge.net/svnroot/apertium/trunk/<modulename>

Note: This command only downloads one module at a time. For a more complete set of instructions on effectively using SVN, see the Using SVN page.


In the area where it says <modulename>, you can replace this with the module that you want to use such as the Spanish/English module.

These next commands download Apertium, lttoolbox, and the language pair that you want to use.

svn co http://apertium.svn.sourceforge.net/svnroot/apertium/trunk/lttoolbox
svn co http://apertium.svn.sourceforge.net/svnroot/apertium/trunk/apertium
svn co https://apertium.svn.sourceforge.net/svnroot/apertium/trunk/<modulename>


For example, if you wanted to get Apertium, lttoolbox, and the Spanish/English module you could enter:

svn co http://apertium.svn.sourceforge.net/svnroot/apertium/trunk/lttoolbox
svn co http://apertium.svn.sourceforge.net/svnroot/apertium/trunk/apertium
svn co https://apertium.svn.sourceforge.net/svnroot/apertium/trunk/apertium-en-es

Note: You can find a full list of modules at https://apertium.svn.sourceforge.net/svnroot/apertium/trunk/.

Normally, Apertium is installed under the directory /usr/local. However, if you want it installed elsewhere or don't want to install it as root, enter:

PREFIX=/path/to/where/I/want/Apertium
PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
export PKG_CONFIG_PATH

Then, in the lttoolbox and apertium directories, do:

./autogen.sh --prefix=$PREFIX
make
make install
ldconfig

Warning: If you didn't specify $PREFIX or don't know what this means then enter:

./autogen.sh 
make
make install
ldconfig

(If you didn't specify a prefix, use sudo before the last two commands.)

Then, in the directory apertium-eo-en, enter:

./autogen.sh --prefix=$PREFIX
make
make install

(Use sudo before the last command if you didn't specify a prefix.)

Final Step: Compilation & Installation

First, you need to compile lttoolbox, Apertium, and your language pair and install them. For this we will use,

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

, for lttoolbox. Then,

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

for Apertium. And finally,

cd ..
cd <modulename>/
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./autogen.sh
make
sudo make install

for your language pair which replaces the text <modulename>.

For further instruction, if necessary, see Apertium on Ubuntu.

Method 2: PACKAGE MANAGER

Using the Synaptic package manager to download and install Apertium, lttoolbox, and your language pair is considerably easier than the terminal method, however, your choice of language pairs is limited, you may be unable to commit changes, and there may possibly be other flaws or minor bugs.

Step 1: Find your Packages

To begin, start by finding the Synaptic package manager and opening it.

Then, use the search box and type in "apertium".

Synaptic should bring up a list of everything related to Apertium. This list should include language pairs, the development versions of lttoolbox and libapertium, as well as the Apertium base package and various others.

Final Step: Compilation & Installation

Luckily, Synaptic takes care of getting the prerequisites, dependencies, and other required packages. All you have to do is select which packages you need and have Synaptic download and install them.

Start by selecting the "apertium" checkbox and choose "Mark for Installation" from the drop-down menu. Left-clicking and right-clicking both bring down the menu.

Synaptic will inform you of Apertium's dependencies and will ask if you want to mark them as well. Click "Mark" in the lower-right of the pop-up box.

The required packages (lttoolbox, libapertim, and liblttoolbox) will now be marked as well.

Now you can select your language pair. Note: Some language pairs aren't available through this method. Those that are available include: en-es fr-es es-pt es-ca es-gl pt-gl eo-ca eo-es en-ca oc-es fr-ca es-ro eu-es oc-ca.

Download and install the selected packages.

Synaptic will inform you when it is done.

Now you can install the development packages (libapertium3-3.1-0-dev and liblttoolbox3-3.1-0-dev) using the same procedures.

IMPORTANT: Available versions of packages may be limited by what version of your OS you are running.

Changing Things Around

When you want to make a change in Apertium, you more than likely want to add a word to an existing language pair.

IMPORTANT: Adding a word won't do you any good if you don't recompile the modules after the change is made. Simply use the terminal like before and enter: make <modulenamehere> and press the "Enter" key and your computer will create the new files necessary.


There are 3 major steps in adding a new word to a language pair:

1. Add an entry to the dictionary for the first language that will be used.

2. Add an entry to the bilingual dictionary for the pair.

3. Add an entry to the dictionary for the second language that will be used.

You will need to find the module you want to work with on your computer and open the three dictionaries; for example: apertium-es-ca.es.dix, apertium-es-ca.es-ca.dix, and apertium-es-ca.ca.dix. Note: Each dictionary will have the suffix ".dix" You should open these files in a text editor or specialized XML editor.

Step 1: Adding to the First Dictionary

When adding entries, you have to enter the lemma (word as you would read it in a dictionary),the part between <i> and </i> that contains the prefix of the word that is common to all inflected forms, and the element in <par> that refers to the inflection paradigm of this word. All entries will have a basic structure like:

      <e lm="(lemma)">
        <i>(prefix)</i>
        <par n="(paradigm)"/>
      </e>


Start by opening your first language's dictionary file. For example: apertium-en-es.es.dix (an XML file).

Then, create a new entry with the basic structure.

Now, between the quotes in the area where it says "(lemma)" replace (lemma) with your word. Note: Do not include () in entries, but place input between "".

Next, you can enter the prefix in the space between <i> and </i> and replace (prefix).

Finally, enter the paradigm in <par> between the quotations. The paradigm should consist of the prefix of another word that has the same inflection and is already in the dictionary and has the morphological analysis: adj m sg, adj f sg, adj m pl and adj f pl respectively. For example: <par n="absolut/o__adj"/>

Now, save your altered dictionary, and DO NOT change file name, directory, or file type.

To finish, use the terminal and enter make <apertiummodule>. Replace <apertiummodule> with your module name. For example: make apertium-en-es. Now press the "Enter" key and allow you computer to recompile the module with the changes you just made.

Step 2: Adding to the Second Dictionary

Using the same structure, you can create the entry in your second language's dictionary that is the equivalent to your entry in the first dictionary.

The second language dictionary file name should be something such as apertium-en-es.en.dix.

Save your changes and recompile the module.

Final Step: The Bilingual Dictionary

Adding entries to the bilingual dictionary is considerably easier than adding to the other two dictionaries. An entry in this dictionary has this basic structure:

     <e> 
        <p>
          <l>(lemmafromfirst)<s n="(partofspeech)"/></l>
          <r>(lemmafromsecond)<s n="(partofspeech)"/></r>
        </p>
      </e>

Simply add an entry and replace (lemmafromfirst) with the lemma you added to the first dictionary, (lemmafromsecond) with the lemma from the second, and (partofspeech) with the part of speech for each word.

Save this dictionary and recompile the module one last time.

See Contributing to an existing pair for a more detailed and full explanation.

Show it to the World

Now that you have added to a language pair you have the option to commit your changes to SourceForge (If you used Method 1 for installation). Committing a change to a language pair is even easier than making the change.

Simply open the terminal, navigate to your language pair that was changed, and enter:

svn commit

Remember to include a log message detailing what was changed or added.