-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_pywrapfst.py
More file actions
51 lines (35 loc) · 1010 Bytes
/
test_pywrapfst.py
File metadata and controls
51 lines (35 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
#-*- coding: utf8 -*-
import os
import sys
from optparse import OptionParser
import time
import pywrapfst as fst
# --verbose
VERBOSE = 0
def num_arcs_and_states(f) :
return sum(1 + f.num_arcs(s) for s in f.states())
if __name__ == '__main__':
parser = OptionParser()
parser.add_option("--verbose", action="store_const", const=1, dest="verbose", help="verbose mode")
(options, args) = parser.parse_args()
if options.verbose == 1 : VERBOSE = 1
startTime = time.time()
f = fst.Fst.read("binary.fst")
for state in f.states() :
for arc in f.arcs(state) :
print state, arc.ilabel, arc.olabel, arc.weight, arc.nextstate
print "num_arcs_and_states = ", num_arcs_and_states(f)
print f
f.draw("f.gv")
'''
while 1 :
try : line = sys.stdin.readline()
except KeyboardInterrupt : break
if not line : break
line = line.strip()
if not line :
continue
'''
durationTime = time.time() - startTime
sys.stderr.write("duration time = %f\n" % durationTime)