Difference between revisions of "Modes"

From Apertium
Jump to navigation Jump to search
m
Line 1: Line 1:
There are a few ways you can use [[pipeline]]s in Apertium. One of them is '''Modes''' files. Modes files (typically called <code>modes.xml</code>) are XML files which specify which programs should be run and in what order. Normally each linguistic package has one of these files which specifies various ways in which you can use the data to perform translations.
There are a few ways you can use [[pipeline]]s in Apertium. One of them is '''Modes''' files. Modes files (typically called <code>modes.xml</code>) are XML files (see [http://apertium.svn.sourceforge.net/viewvc/apertium/trunk/apertium/apertium/modes.dtd modes.dtd]) which specify which programs should be run and in what order. Normally each linguistic package has one of these files which specifies various ways in which you can use the data to perform translations.

See the [http://apertium.svn.sourceforge.net/viewvc/apertium/trunk/apertium-es-ca/modes.xml modes file from es-ca] for an example. The modes which do not say <code>install="yes"</code> are only usable with the -d switch to apertium, these are typically used during development (eg. ca-es-anmor which only performs morphological analysis on Catalan and nothing else).




Line 32: Line 34:
==See also==
==See also==


*[[Mixed modes]]
* [[Mixed modes]]


[[Category:Documentation]]
[[Category:Documentation]]

Revision as of 12:06, 30 March 2010

There are a few ways you can use pipelines in Apertium. One of them is Modes files. Modes files (typically called modes.xml) are XML files (see modes.dtd) which specify which programs should be run and in what order. Normally each linguistic package has one of these files which specifies various ways in which you can use the data to perform translations.

See the modes file from es-ca for an example. The modes which do not say install="yes" are only usable with the -d switch to apertium, these are typically used during development (eg. ca-es-anmor which only performs morphological analysis on Catalan and nothing else).


Statistics mode

In order to get some statistical information about translations made using Apertium, we've hacked the main translation mode, pausing the pipeline just after disambiguation and saving the output into a temp file. After that, pipeline is resumed with temp file as stdin.

As an example, you can se the /broken/ pipeline for ca-es, installed as ca-es-estadistiques.mode

/usr/local/bin/lt-proc /usr/local/share/apertium/apertium-es-ca/ca-es.automorf.bin > $LOGSDIR$SEC.tmp;
/usr/local/bin/apertium-tagger -g /usr/local/share/apertium/apertium-es-ca/ca-es.prob < $LOGSDIR$SEC.tmp \
|/usr/local/bin/apertium-pretransfer|/usr/local/bin/apertium-transfer /usr/local/share/apertium/apertium-es-ca/apertium-es-ca.trules-ca-es.xml \
/usr/local/share/apertium/apertium-es-ca/trules-ca-es.bin  /usr/local/share/apertium/apertium-es-ca/ca-es.autobil.bin \
|/usr/local/bin/lt-proc $1 /usr/local/share/apertium/apertium-es-ca/ca-es.autogen.bin \
|/usr/local/bin/lt-proc -p /usr/local/share/apertium/apertium-es-ca/ca-es.autopgen.bin

And an example of calling apertium with this mode would be the following

LOGSDIR=~/logs/apertium/; SEC=`date +%s`;
echo "Ara Apertium permet extraure estadístiques" | apertium ca-es-estadistiques

In that example, $LOGSDIR is a folder where the logs will be saved, and $SEC is an unique ID for that log.

When translation is done, we can process the log created in order to get statistics.


See also