diff options
author | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2012-07-08 14:26:51 +0200 |
---|---|---|
committer | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2012-07-08 14:26:51 +0200 |
commit | c139ce495861bb341e1b86a85ad4559f9ad53c14 (patch) | |
tree | 1071839ee458f21f169ce06fc536fefe07e4c65d /python/src/lattice.pxi | |
parent | 3a94ac22e5c60aa205f2b3dadf81b0666500e0c3 (diff) | |
parent | d01e5b66d3010d61b9b56301fd7f302dd4ea5bc8 (diff) |
Merge branch 'master' of github.com:pks/cdec-dtrain
Diffstat (limited to 'python/src/lattice.pxi')
-rw-r--r-- | python/src/lattice.pxi | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/python/src/lattice.pxi b/python/src/lattice.pxi index 493c6dcd..f8341e29 100644 --- a/python/src/lattice.pxi +++ b/python/src/lattice.pxi @@ -54,3 +54,15 @@ cdef class Lattice: def __dealloc__(self): del self.lattice + + def todot(self): + def lines(): + yield 'digraph lattice {' + yield 'rankdir = LR;' + yield 'node [shape=circle];' + for i in range(len(self)): + for label, weight, delta in self[i]: + yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) + yield '%d [shape=doublecircle]' % len(self) + yield '}' + return '\n'.join(lines()).encode('utf8') |