Difference between revisions of "Postgenerator"

From Apertium
Jump to navigation Jump to search
Line 72: Line 72:

Latest revision as of 15:47, 24 August 2019

Sometimes you want to be able to merge two tokens in output, for example for contractions, e.g. de + el = del.

You can do this using the postgenerator.

First make sure you add the postgenerator wakeup symbol to your monolingual dictionary, e.g. apertium-aaa.aaa.dix


   <pardef n="/de__pr">
     <e r="LR"><p><l>de</l><r>de<s n="pr"/></r></p></e>
     <e r="RL"><p><l><a/>de</l><r>de<s n="pr"/></r></p></e>


   <e lm="de"><i></i><par n="/de__pr"/></e>


You should get entries like:


from lt-expand apertium-aaa.aaa.dix. apertium-aaa.post-aaa.dix:

<?xml version="1.0" encoding="UTF-8"?>
    <sdef n="test"/>
  <section id="main" type="standard">

     <e> <p><l><a/>de<b/>el</l><r>del</r></p></e>

You can compile it like:

$ lt-comp lr apertium-aaa.post-aaa.dix aaa.autopgen.bin
main@standard 7 6

And use it like:

$ echo "~de el" | lt-proc -p aaa.autopgen.bin 

In your modes file:

      <program name="lt-proc $1">
        <file name="aaa-bbb.autogen.bin"/>
      <program name="lt-proc -p">
        <file name="aaa-bbb.autopgen.bin"/>