mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-12 04:32:50 -06:00
Build SLF networks with sublattices.
This commit is contained in:
@@ -22,7 +22,7 @@ module GF.Speech.FiniteState (FA, State, NFA, DFA,
|
||||
oneFinalState,
|
||||
moveLabelsToNodes, minimize,
|
||||
dfa2nfa,
|
||||
prFAGraphviz) where
|
||||
prFAGraphviz, faToGraphviz) where
|
||||
|
||||
import Data.List
|
||||
import Data.Maybe
|
||||
@@ -213,13 +213,14 @@ dfa2nfa = mapTransitions Just
|
||||
--
|
||||
|
||||
prFAGraphviz :: (Eq n,Show n) => FA n String String -> String
|
||||
prFAGraphviz = Dot.prGraphviz . toGraphviz
|
||||
prFAGraphviz = Dot.prGraphviz . faToGraphviz ""
|
||||
|
||||
prFAGraphviz_ :: (Eq n,Show n,Show a, Show b) => FA n a b -> String
|
||||
prFAGraphviz_ = Dot.prGraphviz . toGraphviz . mapStates show . mapTransitions show
|
||||
prFAGraphviz_ = Dot.prGraphviz . faToGraphviz "" . mapStates show . mapTransitions show
|
||||
|
||||
toGraphviz :: (Eq n,Show n) => FA n String String -> Dot.Graph
|
||||
toGraphviz (FA (Graph _ ns es) s f) = Dot.Graph Dot.Directed [] (map mkNode ns) (map mkEdge es)
|
||||
faToGraphviz :: (Eq n,Show n) => String -- ^ Graph ID
|
||||
-> FA n String String -> Dot.Graph
|
||||
faToGraphviz i (FA (Graph _ ns es) s f) = Dot.Graph Dot.Directed i [] (map mkNode ns) (map mkEdge es) []
|
||||
where mkNode (n,l) = Dot.Node (show n) attrs
|
||||
where attrs = [("label",l)]
|
||||
++ if n == s then [("shape","box")] else []
|
||||
@@ -231,4 +232,4 @@ toGraphviz (FA (Graph _ ns es) s f) = Dot.Graph Dot.Directed [] (map mkNode ns)
|
||||
--
|
||||
|
||||
lookups :: Ord k => [k] -> Map k a -> [a]
|
||||
lookups xs m = mapMaybe (flip Map.lookup m) xs
|
||||
lookups xs m = mapMaybe (flip Map.lookup m) xs
|
||||
|
||||
Reference in New Issue
Block a user