diff options
| author | aarne <aarne@chalmers.se> | 2009-10-07 16:18:33 +0000 |
|---|---|---|
| committer | aarne <aarne@chalmers.se> | 2009-10-07 16:18:33 +0000 |
| commit | 9896fcaad1c1e30e7b2c1129c94fc7c2117d501b (patch) | |
| tree | 651411f3466e6033de02794aac4a3af39f9aa348 /src/GF/Command/Commands.hs | |
| parent | e5609907274298dc8f41cbe170b2b6a253ed1b7a (diff) | |
parse tree visualization command vp
Diffstat (limited to 'src/GF/Command/Commands.hs')
| -rw-r--r-- | src/GF/Command/Commands.hs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/GF/Command/Commands.hs b/src/GF/Command/Commands.hs index 97685b7ce..5fdceee58 100644 --- a/src/GF/Command/Commands.hs +++ b/src/GF/Command/Commands.hs @@ -564,6 +564,42 @@ allCommands cod env@(pgf, mos) = Map.fromList [ return $ fromString out, options = transliterationPrintNames }), + + ("vp", emptyCommandInfo { + longname = "visualize_parse", + synopsis = "show parse tree graphically", + explanation = unlines [ + "Prints a parse tree the .dot format (the graphviz format).", + "The graph can be saved in a file by the wf command as usual.", + "If the -view flag is defined, the graph is saved in a temporary file", + "which is processed by graphviz and displayed by the program indicated", + "by the flag. The target format is png, unless overridden by the", + "flag -format." + ], + exec = \opts es -> do + let lang = optLang opts + let grph = if null es then [] else parseTree Nothing pgf lang (head es) + if isFlag "view" opts || isFlag "format" opts then do + let file s = "_grph." ++ s + let view = optViewGraph opts ++ " " + let format = optViewFormat opts + writeFile (file "dot") (enc grph) + system $ "dot -T" ++ format ++ " " ++ file "dot" ++ " > " ++ file format ++ + " ; " ++ view ++ file format + return void + else return $ fromString grph, + 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" + ], + options = [ + ], + flags = [ + ("format","format of the visualization file (default \"png\")"), + ("view","program to open the resulting file (default \"open\")") + ] + }), + ("vt", emptyCommandInfo { longname = "visualize_tree", synopsis = "show a set of trees graphically", |
