Difference between revisions of "Modes"

From Apertium
Jump to navigation Jump to search
(svn url)
Line 3: Line 3:
 
See the [http://sourceforge.net/p/apertium/svn/HEAD/tree/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).
 
See the [http://sourceforge.net/p/apertium/svn/HEAD/tree/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).
   
  +
== Modes hacks ==
 
== Statistics mode ==
+
=== 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.
 
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.
Line 30: Line 30:
 
When translation is done, we can process the log created in order to get statistics.
 
When translation is done, we can process the log created in order to get statistics.
   
==See also==
+
=== Mixed modes ===
   
* [[Mixed modes]]
+
See [[Mixed modes]]
   
 
[[Category:Documentation]]
 
[[Category:Documentation]]

Revision as of 13:49, 14 March 2014

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).

Modes hacks

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 see 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.

Mixed modes

See Mixed modes