diff options
author | David Robillard <d@drobilla.net> | 2007-03-17 03:15:44 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-03-17 03:15:44 +0000 |
commit | a716b2c0571f5bdcd817835cecb30cb7a4c745e0 (patch) | |
tree | 138a04f89579a435c5f6d93b2bf5e6d9e61ca466 /util | |
parent | cb6ecc0c93b7ea7624dba5d633ff0f15980c4274 (diff) | |
download | machina-a716b2c0571f5bdcd817835cecb30cb7a4c745e0.tar.gz machina-a716b2c0571f5bdcd817835cecb30cb7a4c745e0.tar.bz2 machina-a716b2c0571f5bdcd817835cecb30cb7a4c745e0.zip |
Nicer automata diagrams from machina2dot.py.
Added midi2machina program.
git-svn-id: http://svn.drobilla.net/lad/machina@362 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'util')
-rwxr-xr-x | util/machina2dot.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/util/machina2dot.py b/util/machina2dot.py index eb89ec8..cb704ef 100755 --- a/util/machina2dot.py +++ b/util/machina2dot.py @@ -16,7 +16,7 @@ parser.parse_into_model(model, "file:" + sys.argv[1]) print """ digraph finite_state_machine { rankdir=LR; - node [shape = doublecircle ]; + node [ shape = circle ]; """, node_durations = { } @@ -30,14 +30,17 @@ SELECT DISTINCT ?n ?dur WHERE { } """) +invis_id = 0; + for result in initial_nodes_query.execute(model): node_id = result['n'].blank_identifier duration = float(result['dur'].literal_value['string']) node_durations[node_id] = duration + print "\t{ node [ style = invis ] ", + print "invis%d" % invis_id, " }" print '\t', node_id, "[ label = \"d =", duration, "\"];" - - -print "\tnode [shape = circle ];" + print '\t', "invis%d" % invis_id, " -> ", node_id + invis_id += 1 nodes_query = RDF.SPARQLQuery(""" @@ -53,7 +56,7 @@ for result in nodes_query.execute(model): node_id = result['n'].blank_identifier duration = float(result['dur'].literal_value['string']) node_durations[node_id] = duration - print '\t', node_id, "[ label = \"d =", duration, "\"]; " + print '\t', node_id, "[ label = \"d =", "%.2f" % duration, "\"]; " edge_query = RDF.SPARQLQuery(""" @@ -69,7 +72,7 @@ SELECT DISTINCT ?tail ?head ?prob WHERE { for edge in edge_query.execute(model): print '\t', edge['tail'].blank_identifier, ' -> ', print edge['head'].blank_identifier, ' ', - print "[ label = \"", edge['prob'].literal_value['string'], "\" ", + print "[ label = \"", "%1.2f" % float(edge['prob'].literal_value['string']), "\" ", print "minlen = ", node_durations[edge['tail'].blank_identifier] * 2, " ];" print "}" |