mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
MaltParser input
This commit is contained in:
@@ -63,12 +63,14 @@ prGraph digr ns = concat $ map (++"\n") $ [graph ++ "{\n"] ++ ns ++ ["}"] where
|
|||||||
dependencyTree :: String -> Bool -> Maybe Labels -> Maybe String -> PGF -> CId -> Expr -> String
|
dependencyTree :: String -> Bool -> Maybe Labels -> Maybe String -> PGF -> CId -> Expr -> String
|
||||||
dependencyTree format debug mlab ms pgf lang exp = case format of
|
dependencyTree format debug mlab ms pgf lang exp = case format of
|
||||||
"malt" -> unlines (lin2dep format)
|
"malt" -> unlines (lin2dep format)
|
||||||
|
"malt_input" -> unlines (lin2dep format)
|
||||||
_ -> prGraph True (lin2dep format)
|
_ -> prGraph True (lin2dep format)
|
||||||
|
|
||||||
where
|
where
|
||||||
|
|
||||||
lin2dep format = trace (ifd (show sortedNodes ++ show nodeWords)) $ case format of
|
lin2dep format = trace (ifd (show sortedNodes ++ show nodeWords)) $ case format of
|
||||||
"malt" -> map (concat . intersperse "\t") wnodes
|
"malt" -> map (concat . intersperse "\t") wnodes
|
||||||
|
"malt_input" -> map (concat . intersperse "\t" . take 6) wnodes
|
||||||
_ -> prelude ++ nodes ++ links
|
_ -> prelude ++ nodes ++ links
|
||||||
|
|
||||||
ifd s = if debug then s else []
|
ifd s = if debug then s else []
|
||||||
@@ -134,8 +136,8 @@ dependencyTree format debug mlab ms pgf lang exp = case format of
|
|||||||
arcMap = Map.fromList [(y,(x,l)) | (x,y,l) <- thelinks]
|
arcMap = Map.fromList [(y,(x,l)) | (x,y,l) <- thelinks]
|
||||||
|
|
||||||
lookDomLab p = case Map.lookup p arcMap of
|
lookDomLab p = case Map.lookup p arcMap of
|
||||||
Just (q,l) -> (maybe 0 id (Map.lookup q nodeMap), if null l then "_" else l)
|
Just (q,l) -> (maybe 0 id (Map.lookup q nodeMap), if null l then rootlabel else l)
|
||||||
_ -> (0,unspec)
|
_ -> (0,rootlabel)
|
||||||
|
|
||||||
wnodes = [[show i, unwords ws, showCId fun, pos, pos, morph, show dom, lab, unspec, unspec] |
|
wnodes = [[show i, unwords ws, showCId fun, pos, pos, morph, show dom, lab, unspec, unspec] |
|
||||||
(i, ((fun,p),ws)) <- tail nodeWords,
|
(i, ((fun,p),ws)) <- tail nodeWords,
|
||||||
@@ -145,6 +147,7 @@ dependencyTree format debug mlab ms pgf lang exp = case format of
|
|||||||
]
|
]
|
||||||
|
|
||||||
unspec = "_"
|
unspec = "_"
|
||||||
|
rootlabel = "ROOT"
|
||||||
|
|
||||||
type Labels = Map.Map CId [String]
|
type Labels = Map.Map CId [String]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user