Difference between revisions of "Modes"

From Apertium
Jump to navigation Jump to search
(Documentation in English)
Line 37: Line 37:
   
 
[[Category:Documentation]]
 
[[Category:Documentation]]
  +
[[Category:Documentation in English]]

Revision as of 18:43, 3 September 2011

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