diff options
| author | krasimir <krasimir@chalmers.se> | 2009-10-24 09:03:40 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2009-10-24 09:03:40 +0000 |
| commit | 59172a0380cc0c9553b2146af1600bbcacde0b2a (patch) | |
| tree | be738dc0d710e17b6bc2d65e6aab9867a47b8baa /src/PGF/VisualizeTree.hs | |
| parent | 0e3e2d03f94fb3705bc3d2ba0ea3e76fdb814691 (diff) | |
expose the tree visualization via PGF API
Diffstat (limited to 'src/PGF/VisualizeTree.hs')
| -rw-r--r-- | src/PGF/VisualizeTree.hs | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/PGF/VisualizeTree.hs b/src/PGF/VisualizeTree.hs index 4919f00f7..bd419e14f 100644 --- a/src/PGF/VisualizeTree.hs +++ b/src/PGF/VisualizeTree.hs @@ -15,9 +15,14 @@ -- instead of rolling its own. ----------------------------------------------------------------------------- -module PGF.VisualizeTree ( visualizeTrees, parseTree, dependencyTree, getDepLabels, - alignLinearize, PosText(..), readPosText - ) where +module PGF.VisualizeTree ( graphvizAbstractTree + , graphvizParseTree + , graphvizDependencyTree + , graphvizAlignment + + , getDepLabels + , PosText(..), readPosText + ) where import PGF.CId (CId,showCId,pCId,mkCId) import PGF.Data @@ -32,8 +37,8 @@ import qualified Text.ParserCombinators.ReadP as RP import Debug.Trace -visualizeTrees :: PGF -> (Bool,Bool) -> [Expr] -> String -visualizeTrees pgf funscats = unlines . map (prGraph False . tree2graph pgf funscats . expr2tree) +graphvizAbstractTree :: PGF -> (Bool,Bool) -> Expr -> String +graphvizAbstractTree pgf funscats = prGraph False . tree2graph pgf funscats . expr2tree tree2graph :: PGF -> (Bool,Bool) -> Tree -> [String] tree2graph pgf (funs,cats) = prf [] where @@ -60,8 +65,8 @@ prGraph digr ns = concat $ map (++"\n") $ [graph ++ "{\n"] ++ ns ++ ["}"] where -- dependency trees from Linearize.linearizeMark -dependencyTree :: String -> Bool -> Maybe Labels -> Maybe String -> PGF -> CId -> Expr -> String -dependencyTree format debug mlab ms pgf lang exp = case format of +graphvizDependencyTree :: String -> Bool -> Maybe Labels -> Maybe String -> PGF -> CId -> Expr -> String +graphvizDependencyTree format debug mlab ms pgf lang exp = case format of "malt" -> unlines (lin2dep format) "malt_input" -> unlines (lin2dep format) _ -> prGraph True (lin2dep format) @@ -158,8 +163,8 @@ getDepLabels ss = Map.fromList [(mkCId f,ls) | f:ls <- map words ss] -- parse trees from Linearize.linearizeMark ---- nubrec and domins are quadratic, but could be (n log n) -parseTree :: Maybe String -> PGF -> CId -> Expr -> String -parseTree ms pgf lang = prGraph False . lin2tree pgf . linMark where +graphvizParseTree :: PGF -> CId -> Expr -> String +graphvizParseTree pgf lang = prGraph False . lin2tree pgf . linMark where linMark = head . linearizesMark pgf lang ---- use Just str if you have str to match against @@ -209,8 +214,8 @@ mtag = tag . ('n':) . uncommas -- word alignments from Linearize.linearizesMark -- words are chunks like {[0,1,1,0] old} -alignLinearize :: PGF -> Expr -> String -alignLinearize pgf = prGraph True . lin2graph . linsMark where +graphvizAlignment :: PGF -> Expr -> String +graphvizAlignment pgf = prGraph True . lin2graph . linsMark where linsMark t = [s | la <- cncnames pgf, s <- take 1 (linearizesMark pgf la t)] lin2graph :: [String] -> [String] |
