diff --git a/finenight/python/fsa.py b/finenight/python/fsa.py index 1e4173a..9bc9a19 100644 --- a/finenight/python/fsa.py +++ b/finenight/python/fsa.py @@ -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: @@ -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") @@ -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() @@ -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") diff --git a/finenight/python/fst.py b/finenight/python/fst.py index 8702d35..a0c858c 100644 --- a/finenight/python/fst.py +++ b/finenight/python/fst.py @@ -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 = "" @@ -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: