diff options
| author | bringert <bringert@cs.chalmers.se> | 2005-12-08 16:01:13 +0000 |
|---|---|---|
| committer | bringert <bringert@cs.chalmers.se> | 2005-12-08 16:01:13 +0000 |
| commit | cb18297acef067f0072ff290bedbb2f11f703eb8 (patch) | |
| tree | 3110c155a29b3cc2286836b8a669f9a1258b7064 /src/GF/Speech/FiniteState.hs | |
| parent | 913a15a083b71c0144d9b8c02dca8c8d3eb7e332 (diff) | |
SLF generation: make sure that there is only one final node, and that it is actually final.
Diffstat (limited to 'src/GF/Speech/FiniteState.hs')
| -rw-r--r-- | src/GF/Speech/FiniteState.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/GF/Speech/FiniteState.hs b/src/GF/Speech/FiniteState.hs index cfcc6e096..dfd5d941d 100644 --- a/src/GF/Speech/FiniteState.hs +++ b/src/GF/Speech/FiniteState.hs @@ -18,6 +18,7 @@ module GF.Speech.FiniteState (FA, State, NFA, DFA, addFinalState, newState, newTransition, mapStates, mapTransitions, + oneFinalState, moveLabelsToNodes, minimize, dfa2nfa, prFAGraphviz) where @@ -79,6 +80,18 @@ minimize = determinize . reverseNFA . dfa2nfa . determinize . reverseNFA onGraph :: (Graph n a b -> Graph n c d) -> FA n a b -> FA n c d onGraph f (FA g s ss) = FA (f g) s ss +-- | Make the finite automaton have a single final state +-- by adding a new final state and adding an edge +-- from the old final states to the new state. +oneFinalState :: a -- ^ Label to give the new node + -> b -- ^ Label to give the new edges + -> FA n a b -- ^ The old network + -> FA n a b -- ^ The new network +oneFinalState nl el fa = + let (FA g s fs,nf) = newState nl fa + es = [ (f,nf,el) | f <- fs ] + in FA (newEdges es g) s [nf] + -- | Transform a standard finite automaton with labelled edges -- to one where the labels are on the nodes instead. This can add -- up to one extra node per edge. |
