From 390566b17e69da2045a49e3da1f8debc60d42ccd Mon Sep 17 00:00:00 2001 From: aarne Date: Fri, 25 Feb 2011 12:55:36 +0000 Subject: [PATCH] command ga moved to option 'aw -giza' --- src/compiler/GF/Command/Commands.hs | 64 ++++++++++++----------------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/GF/Command/Commands.hs index d4e8e406b..f7a34ee27 100644 --- a/src/compiler/GF/Command/Commands.hs +++ b/src/compiler/GF/Command/Commands.hs @@ -156,51 +156,41 @@ allCommands env@(pgf, mos) = Map.fromList [ ], exec = \opts es -> do let langs = optLangs opts - let grph = if null es then [] else graphvizAlignment pgf langs (head es) - if isFlag "view" opts || isFlag "format" opts then do - let file s = "_grph." ++ s - let view = optViewGraph opts - let format = optViewFormat opts - writeUTF8File (file "dot") grph - system $ "dot -T" ++ format ++ " " ++ file "dot" ++ " > " ++ file format - system $ view ++ " " ++ file format - return void - else return $ fromString grph, + if isOpt "giza" opts + then do + let giz = map (gizaAlignment pgf (head $ langs, head $ tail $ langs)) es + let lsrc = unlines $ map (\(x,_,_) -> x) giz + let ltrg = unlines $ map (\(_,x,_) -> x) giz + let align = unlines $ map (\(_,_,x) -> x) giz + let grph = if null es then [] else lsrc ++ "\n--end_source--\n\n"++ltrg++"\n-end_target--\n\n"++align + return $ fromString grph + else do + let grph = if null es then [] else graphvizAlignment pgf langs (head es) + if isFlag "view" opts || isFlag "format" opts + then do + let file s = "_grph." ++ s + let view = optViewGraph opts + let format = optViewFormat opts + writeUTF8File (file "dot") grph + system $ "dot -T" ++ format ++ " " ++ file "dot" ++ " > " ++ file format + system $ 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" + "gr | aw -- generate a tree and show word alignment as graph script", + "gr | aw -view=\"open\" -- generate a tree and display alignment on Mac", + "gr | aw -view=\"eog\" -- generate a tree and display alignment on Ubuntu", + "gt | aw -giza | wf -file=aligns -- generate trees, send giza alignments to file" ], options = [ + ("giza", "show alignments in the Giza format; the first two languages") ], flags = [ ("format","format of the visualization file (default \"png\")"), - ("lang", "alignments for this list of languages (default: all)"), - ("view", "program to open the resulting file (default \"open\")") + ("lang", "alignments for this list of languages (default: all)"), + ("view", "program to open the resulting file") ] }), - ("ga", emptyCommandInfo { - longname = "giza_alignment", - synopsis = "show the giza alignment between 2 languages", - explanation = unlines [ - "Prints a set of alignments in the .txt format.", - "The graph can be saved in a file by the wf command as usual." - ], - exec = \opts es -> do - let giz = map (gizaAlignment pgf (head $ languages pgf, head $ tail $ languages pgf)) es - let lsrc = unlines $ map (\(x,_,_) -> x) giz - let ltrg = unlines $ map (\(_,x,_) -> x) giz - let align = unlines $ map (\(_,_,x) -> x) giz - let grph = if null es then [] else lsrc ++ "\n--end_source--\n\n"++ltrg++"\n-end_target--\n\n"++align - return $ fromString grph, - examples = [ - "gr | ga -- generate a tree and show giza alignments" - ], - options = [ - ], - flags = [ - ] - }), - ("ca", emptyCommandInfo { longname = "clitic_analyse", synopsis = "print the analyses of all words into stems and clitics",