5
def lattice_s3(latfile):
9
if line.startswith("Nodes"):
12
if line.startswith("Edges"):
15
if line.startswith("#") or line.startswith("End"):
19
items = line.strip().split(" ")
22
print items[0] + " [label = \"" + items[1] + " " + items[2] + " " + items[3] + " " + items[4] + "\"];"
24
print "node " + items[0] + ";"
26
print items[0] + " -> " + items[1] + " [label = \"" + items[2] + "\"];"
29
def create_map(items):
35
def lattice_htk_wordnode(latfile):
38
items = line.strip().split()
39
if items[0].startswith("I="):
40
dct = create_map(items)
42
print dct["J"] + " [label = \"" + dct[W] + "\"];"
43
if items[0].startswith("J="):
44
dct = create_map(items)
46
print dct["S"] + " -> " + dct["E"] + " [label = \"" + dct["W"] + "," + dct["a"] + "," + dct["l"] + "\"];"
48
print dct["S"] + " -> " + dct["E"] + " [label = \"" + dct["a"] + "," + dct["l"] + "\"];"
51
if __name__ == '__main__':
52
latfilename = sys.argv[1]
53
latfile = open(latfilename, "r")
60
if latfilename.endswith("slf"):
61
lattice_htk_wordnode(latfile)