summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Command
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2011-02-25 12:55:36 +0000
committeraarne <aarne@chalmers.se>2011-02-25 12:55:36 +0000
commit390566b17e69da2045a49e3da1f8debc60d42ccd (patch)
treecd3c4dcb43910ae38d3f172569dc96905ad41851 /src/compiler/GF/Command
parentc51c011dda7c9ced5038d98e1fc2ea419e0d90a7 (diff)
command ga moved to option 'aw -giza'
Diffstat (limited to 'src/compiler/GF/Command')
-rw-r--r--src/compiler/GF/Command/Commands.hs64
1 files 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\")")
- ]
- }),
- ("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 = [
+ ("lang", "alignments for this list of languages (default: all)"),
+ ("view", "program to open the resulting file")
]
}),
-
("ca", emptyCommandInfo {
longname = "clitic_analyse",
synopsis = "print the analyses of all words into stems and clitics",