Task ideas for Google Code-in/Print transducer with n cycles

From Apertium
Jump to navigation Jump to search

<spectre> imagine you have a dictionary like this:
<spectre> <dictionary>
<spectre>   <alphabet>ab</alphabet>
<spectre>   <sdefs/>
<spectre>   <section id="main" type="standard">
<spectre>     <e><re>ab+</re></e>
<spectre>   </section>
<spectre> </dictionary>
<spectre> $ lt-comp lr /tmp/foo.dix  /tmp/foo.bin
<spectre> main@standard 3 3
<spectre> $ lt-print /tmp/foo.bin 
<spectre> 0 1 a a 
<spectre> 1 2 b b 
<spectre> 2 2 b b 
<spectre> 2
<spectre> you can see '2 2 b b ' is a cycle
<spectre> it allows a and any number of b
<spectre> $ echo "abb" | lt-proc /tmp/foo.bin 
<spectre> ^abb/abb$
<spectre> $ echo "abbb" | lt-proc /tmp/foo.bin 
<spectre> ^abbb/abbb$
<spectre> but not:
<spectre> $ echo "abbba" | lt-proc /tmp/foo.bin 
<spectre> ^abbba/*abbba$
<spectre> so, the idea is to print out all the strings accepted by the transducer
<spectre> but only following cycles n times
<spectre> so given this transducer
<spectre> lt-print -n 2 /tmp/foo.bin
<spectre> would give:
<spectre> ab:ab
<spectre> abb:abb
<spectre> and
<spectre> lt-print -n 3 /tmp/foo.bin
<spectre> would give:
<spectre> ab:ab
<spectre> abb:abb
<spectre> abbb:abbb
<spectre> relevant files are:
<spectre> URL: https://svn.code.sf.net/p/apertium/svn/trunk/lttoolbox/lttoolbox/lt_print.cc
<spectre> URL: https://svn.code.sf.net/p/apertium/svn/trunk/lttoolbox/lttoolbox/transducer.cc
<spectre> relevant functions are:
<spectre> Transducer::show(Alphabet const &alphabet, FILE *output, int const epsilon_tag) const