Skip to content

Commit

Permalink
fixed some problems
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbarrette committed Nov 24, 2009
1 parent d1ee5ae commit 94fdc83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
12 changes: 6 additions & 6 deletions finenight/python/fsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def graphVizExport(self, filename, size = (8,11)):
if self.finalStates:
f.write("node [shape = doublecircle];\n")
for state in self.finalStates:
f.write("\"" + state + "\" ")
f.write("\"" + str(state) + "\" ")
f.write(";\n")

if self.states:
Expand All @@ -160,7 +160,7 @@ def graphVizExport(self, filename, size = (8,11)):

for state in self.states.values():
for epsilon in state.epsilon:
f.write("\"" + state.name +
f.write("\"" + str(state.name) +
"\" -> \"" +
epsilon +
"\" [fontname=\"Symbol\", label=\"e\"];\n")
Expand All @@ -169,11 +169,11 @@ def graphVizExport(self, filename, size = (8,11)):
if transitions.__class__ is not [].__class__:
transitions = [transitions]
for transition in transitions:
f.write("\"" + state.name +
f.write("\"" + str(state.name) +
"\" -> \"" +
transition +
str(transition) +
"\" [ label = \"" +
symbol +
str(symbol) +
"\" ];\n")
f.write("}\n")
f.close()
Expand Down Expand Up @@ -262,7 +262,7 @@ def __init__(self, states, alphabet, startState, finalStates):
for input in invalidInputs:
output += input + ", "
raise ConstructionError("symbol " + output[:-2] + "in " + \
state.name + \
str(state.name) + \
" state is/are not part of the alphabet")


Expand Down
11 changes: 4 additions & 7 deletions finenight/python/fst.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@





class FstState:
def __init__(self):
self.name = None
self.transitions = {}
class FstState(State):
def __init__(self, name):
State.__init__(self, name)

def __str__(self):
output = ""
Expand Down Expand Up @@ -140,7 +137,7 @@ def add(self, state):

if state.__class__ == Transition:
if not self.states.has_key(state.start):
self.states[state.start] = FstState()
self.states[state.start] = FstState(state.start)
self.states[state.start].add(state)

if state.__class__ == FstState:
Expand Down

0 comments on commit 94fdc83

Please sign in to comment.