diff options
| author | aarne <aarne@chalmers.se> | 2009-10-20 13:04:33 +0000 |
|---|---|---|
| committer | aarne <aarne@chalmers.se> | 2009-10-20 13:04:33 +0000 |
| commit | e82b6e02e991e482de04619a5694e8d765d2730b (patch) | |
| tree | b86651b6c95cb83aaee510594d3ac59c198fed1a /src/GF/Command | |
| parent | 499ac428d32ada9979c2ff41bd23582245fb4715 (diff) | |
Malt parser .conll format by vd -output=malt
Diffstat (limited to 'src/GF/Command')
| -rw-r--r-- | src/GF/Command/Commands.hs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/GF/Command/Commands.hs b/src/GF/Command/Commands.hs index e297bb6b8..1b12d82cc 100644 --- a/src/GF/Command/Commands.hs +++ b/src/GF/Command/Commands.hs @@ -569,7 +569,8 @@ allCommands cod env@(pgf, mos) = Map.fromList [ longname = "visualize_dependency", synopsis = "show word dependency tree graphically", explanation = unlines [ - "Prints a dependency tree the .dot format (the graphviz format).", + "Prints a dependency tree in the .dot format (the graphviz format, default)", + "or the MaltParser/CoNLL format (flag -output=malt)", "By default, the last argument is the head of every abstract syntax", "function; moreover, the head depends on the head of the function above.", "The graph can be saved in a file by the wf command as usual.", @@ -581,21 +582,21 @@ allCommands cod env@(pgf, mos) = Map.fromList [ exec = \opts es -> do let debug = isOpt "v" opts let file = valStrOpts "file" "" opts + let outp = valStrOpts "output" "dot" opts mlab <- case file of "" -> return Nothing _ -> readFile file >>= return . Just . getDepLabels . lines let lang = optLang opts - let grph = if null es then [] else - dependencyTree debug mlab Nothing pgf lang (head es) + let grphs = unlines $ map (dependencyTree outp debug mlab Nothing pgf lang) es if isFlag "view" opts || isFlag "format" opts then do - let file s = "_grph." ++ s + let file s = "_grphd." ++ s let view = optViewGraph opts ++ " " let format = optViewFormat opts - writeFile (file "dot") (enc grph) + writeFile (file "dot") (enc grphs) system $ "dot -T" ++ format ++ " " ++ file "dot" ++ " > " ++ file format ++ " ; " ++ view ++ file format return void - else return $ fromString grph, + else return $ fromString grphs, examples = [ "gr | aw -- generate a tree and show word alignment as graph script", "gr | vt -view=\"open\" -- generate a tree and display alignment on a Mac" @@ -606,6 +607,7 @@ allCommands cod env@(pgf, mos) = Map.fromList [ flags = [ ("file","configuration file for labels per fun, format 'fun l1 ... label ... l2'"), ("format","format of the visualization file (default \"png\")"), + ("output","output format of graph source (default \"dot\")"), ("view","program to open the resulting file (default \"open\")") ] }), |
