fst2dot Finite State Transducer Visualizer
fst2dot translates SFST transducers to Graphviz dot files.
Introduction
fst2dot is a filter script that allows to visualize transducers generated by SFST using Graphviz. It is written in Perl and easy to use.
Especially sfst
beginners may consider fst2dot
useful in order to get a
quick overview on what their transducers look like.
Usage Example
fst2dot takes fst-print
's output and generates a graphviz dot-file from
that input. Graphivz can than produce a pritty graph of your automata.
Here's a complete example:
$TEST$ = Dach | Fach | Bach | dich | mich | sich
$TEST$
Now, compile the transducer and feed the output of fst-print
to fst2dot.pl
:
$ fst-compiler test.fst test.a
test.fst: 4
$ fst-print test.a | perl fst2dot.pl - > test.dot
The resulting dot file looks like this:
# automatically generated by fst2dot v0.2
digraph agraph
{
rankdir="LR";
node [shape="circle", label=""];
0 -> 1 [label="B"];
0 -> 1 [label="D"];
0 -> 1 [label="F"];
0 -> 5 [label="d"];
0 -> 5 [label="m"];
0 -> 5 [label="s"];
1 -> 2 [label="a"];
2 -> 3 [label="c"];
3 -> 4 [label="h"];
4 [shape="doublecircle"]
5 -> 2 [label="i"];
}
Graphviz can now use "test.dot" as an input to produce a fancy graph:
$ dot -Tpng -o test.png test.dot
As a shortcut, the last steps may be combined using pipes:
$ fst-print test.a | fst2dot - | dot -Tpng -o test.png
Please note that in the above example fst2dot.pl
has been renamed to
fst2dot
, given execute permissions ("chmod a+x fst2dot
") and placed in
a directory listed in $PATH
.
Requirements
- Perl >= 5.8.0
- SFST, the Stuttgart Finite State Transducer Tools
- Graphviz, a Graph Visualization Software
Download & License
The current version of fst2dot (0.2) is suitable for SFST version >= 1.3 and can be downloaded here: fst2dot.pl.
The 0.1 version, which is suitable for SFST versions below 1.3, is still available here: fst2dot-v0.1.pl.
fst2dot is available under the terms of the MIT license.
xfst2dot
Please note: fst2dot doesn't work with the Xerox Finite State Tools
- it requires the Stuttgart Finite State Transducer Tools.
A similar script which is used in the same way is available for download, too:
xfst2dot.pl.
Anyway, I haven't used it for a long time, because I don't use
xfst
anymore, so you're on your own with this one.