-
Notifications
You must be signed in to change notification settings - Fork 1
/
make_T.py
52 lines (39 loc) · 1.08 KB
/
make_T.py
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
52
#!/usr/bin/env python
#-*- coding: utf8 -*-
import os
import sys
from optparse import OptionParser
import time
# --verbose
VERBOSE = 0
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()
# ε = lowercase epsilon
alphabet = "abc"
weight = {
"delete": 1.0,
"insert": 1.0,
"sub": 1.0
}
# No edit
for l in alphabet:
print "0 0 %s %s %.3f" % (l, l, 0)
# Deletes: input character, output epsilon
for l in alphabet:
print "0 0 %s ε %.3f" % (l, weight["delete"])
# Insertions: input epsilon, output character
for l in alphabet:
print "0 0 ε %s %.3f" % (l, weight["insert"])
# Substitutions: input one character, output another
for l in alphabet:
for r in alphabet:
if l is not r:
print "0 0 %s %s %.3f" % (l, r, weight["sub"])
# Final state
print 0
durationTime = time.time() - startTime
sys.stderr.write("duration time = %f\n" % durationTime)