summaryrefslogtreecommitdiff
path: root/src/runtime/haskell
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2013-04-16 18:22:37 +0000
committerkr.angelov <kr.angelov@gmail.com>2013-04-16 18:22:37 +0000
commitb49b9d459a5027013df12b826291c91899aece7e (patch)
tree078c92b6de0e16094b5104fa6f4c5f7ffa2423c4 /src/runtime/haskell
parentf6d675c34bdb42d3fc64c99feab7a71d32551298 (diff)
added a malt_tab format to the vd command in the GF shell
Diffstat (limited to 'src/runtime/haskell')
-rw-r--r--src/runtime/haskell/PGF/VisualizeTree.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/runtime/haskell/PGF/VisualizeTree.hs b/src/runtime/haskell/PGF/VisualizeTree.hs
index 48d86cf26..d0fc3a9e3 100644
--- a/src/runtime/haskell/PGF/VisualizeTree.hs
+++ b/src/runtime/haskell/PGF/VisualizeTree.hs
@@ -37,7 +37,7 @@ import PGF.Macros (lookValCat, lookMap,
import qualified Data.Map as Map
import qualified Data.IntMap as IntMap
-import Data.List (intersperse,nub,mapAccumL)
+import Data.List (intersperse,nub,mapAccumL,find)
import Data.Char (isDigit)
import Data.Maybe (fromMaybe)
import Text.PrettyPrint
@@ -120,6 +120,7 @@ graphvizDependencyTree :: String -> Bool -> Maybe Labels -> Maybe String -> PGF
graphvizDependencyTree format debug mlab ms pgf lang t = render $
case format of
"conll" -> vcat (map (hcat . intersperse (char '\t') ) wnodes)
+ "malt_tab" -> vcat (map (hcat . intersperse (char '\t') . (\ws -> [ws !! 0,ws !! 1,ws !! 3,ws !! 6,ws !! 7])) wnodes)
"malt_input" -> vcat (map (hcat . intersperse (char '\t') . take 6) wnodes)
_ -> text "digraph {" $$
space $$
@@ -134,9 +135,10 @@ graphvizDependencyTree format debug mlab ms pgf lang t = render $
wnodes = [[int i, maltws ws, ppCId fun, ppCId cat, ppCId cat, unspec, int parent, text lab, unspec, unspec] |
((cat,fid,fun),i,ws) <- tail leaves,
- let (lab,parent) = maybe (dep_lbl,0)
- (\(lbl,fid) -> (lbl,head [i | ((_,fid1,_),i,_) <- leaves, fid == fid1]))
- (lookup fid deps)
+ let (lab,parent) = fromMaybe (dep_lbl,0)
+ (do (lbl,fid) <- lookup fid deps
+ (_,i,_) <- find (\((_,fid1,_),i,_) -> fid == fid1) leaves
+ return (lbl,i))
]
maltws = text . concat . intersperse "+" . words -- no spaces in column 2