summaryrefslogtreecommitdiff
path: root/src/GF
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-12-15 10:33:53 +0000
committeraarne <aarne@cs.chalmers.se>2008-12-15 10:33:53 +0000
commit10675e29cac9149c18fbf61903e52468426a0ea1 (patch)
treeb3ff5b65d83080b1b2b24d296e92ef9d2ae50f0f /src/GF
parent3e293ae3e0b9664fadb118d013563be52f0e5885 (diff)
visualization of word alignment based on bracketing (command aw); does not work for syncategorematic words yet
Diffstat (limited to 'src/GF')
-rw-r--r--src/GF/Command/Commands.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/GF/Command/Commands.hs b/src/GF/Command/Commands.hs
index a78fa0fac..5674f1107 100644
--- a/src/GF/Command/Commands.hs
+++ b/src/GF/Command/Commands.hs
@@ -104,6 +104,41 @@ allCommands cod env@(pgf, mos) = Map.fromList [
"gt | l | ? wc -- generate, linearize, word-count"
]
}),
+
+ ("aw", emptyCommandInfo {
+ longname = "align_words",
+ synopsis = "show word alignments between languages graphically",
+ explanation = unlines [
+ "Prints a set of strings in 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 postscript, unless overridden by the",
+ "flag -format."
+ ],
+ exec = \opts ts -> do
+ let grph = if null ts then [] else alignLinearize pgf (head ts)
+ 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 \"ps\")"),
+ ("view","program to open the resulting file (default \"gv\")")
+ ]
+ }),
+
("cc", emptyCommandInfo {
longname = "compute_concrete",
syntax = "cc (-all | -table | -unqual)? TERM",