There is a popular format for transducers called ATT format, which is
basically just a text file with:
input state \t output state \t input label \t output label
I've added a function to the Transducer class called "show()" which
prints out an Apertium transducer in this format. (see diff)
This is fairly unobtrusive (doesn't require any changes in existing
functions), and allows cool stuff to be generated with graphviz fairly
easily, like:
http://imageshack.us/f/683/fomagbiodl.png/
(I did this one with foma, but the format is fairly straightforward and
it should be easy to write scripts)
If there are no complaints, i'll commit the diff.
Fran
Index: transducer.cc
===================================================================
--- transducer.cc (revision 34359)
+++ transducer.cc (working copy)
@@ -18,6 +18,7 @@
*/
#include <lttoolbox/transducer.h>
#include <lttoolbox/compression.h>
+#include <lttoolbox/alphabet.h>
#include <lttoolbox/lttoolbox_config.h>
#include <lttoolbox/my_stdio.h>
@@ -609,3 +610,35 @@
finals.clear();
finals.insert(tmp);
}
+
+void
+Transducer::show(Alphabet &alphabet, FILE *output, int const epsilon_tag)
+{
+ joinFinals(epsilon_tag);
+
+ map<int, multimap<int, int> > temporal;
+
+ for(map<int, multimap<int, int> >::iterator it = transitions.begin(); it != transitions.end(); it++)
+ {
+ multimap<int, int> aux = it->second;
+
+ for(multimap<int, int>::iterator it2 = aux.begin(); it2 != aux.end(); it2++)
+ {
+ pair<int, int> t = alphabet.decode(it2->first);
+ fwprintf(output, L"%d\t", it->first);
+ fwprintf(output, L"%d\t", it2->second);
+ wstring l = L"";
+ alphabet.getSymbol(l, t.first);
+ fwprintf(output, L"%S\t", l.c_str());
+ wstring r = L"";
+ alphabet.getSymbol(r, t.second);
+ fwprintf(output, L"%S", r.c_str());
+ fwprintf(output, L"\n");
+ }
+ }
+
+ for(set<int>::iterator it3 = finals.begin(); it3 != finals.end(); it3++)
+ {
+ fwprintf(output, L"%d\n", *it3);
+ }
+}
Index: transducer.h
===================================================================
--- transducer.h (revision 34359)
+++ transducer.h (working copy)
@@ -179,6 +179,12 @@
void reverse(int const epsilon_tag = 0);
/**
+ * Print all the transductions of a transducer
+ * @param epsilon_tag the tag to take as epsilon
+ */
+ void show(Alphabet &a, FILE *output = stdout, int const epsilon_tag = 0);
+
+ /**
* Determinize the transducer
* @param epsilon_tag the tag to take as epsilon
*/
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
Apertium-stuff mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/apertium-stuff