1
0
forked from GitHub/gf-core

l -multi -all/-table ; same with tb

This commit is contained in:
aarne
2006-05-30 22:02:25 +00:00
parent 719e751051
commit c51846361f
7 changed files with 43 additions and 23 deletions

View File

@@ -12,6 +12,9 @@ Changes in functionality since May 17, 2005, release of GF Version 2.2
</center>
30/5 (AR) It is now possible to use the flags <tt>-all, -table, -record</tt>
in combination with <tt>l -multi</tt>, and also with <tt>tb</tt>.
<p>
18/5 (AR) Introduced a wordlist format <tt>gfwl</tt> for

View File

@@ -1910,7 +1910,7 @@ of such a theory, represented as an ``abstract`` module in GF.
A resource grammar is a grammar built on linguistic grounds,
to describe a language rather than a domain.
The GF resource grammar library contains resource grammars for
The GF resource grammar library, which contains resource grammars for
10 languages, is described more closely in the following
documents:
- [Resource library API documentation ../../lib/resource-1.0/doc/]:

View File

@@ -231,8 +231,11 @@ execC co@(comm, opts0) sa@(sh@(st,(h,_,_,_)),a) = checkOptions st co >> case com
CLinearize []
| oElem showMulti opts ->
changeArg (opTS2CommandArg (unlines. linearizeToAll
(allStateGrammars st)) . s2t) sa
changeArg (opTS2CommandArg (
unlines .
(\t -> [optLinearizeTreeVal opts gr t | gr <- allStateGrammars st])) . s2t) sa
| otherwise -> changeArg (opTS2CommandArg (optLinearizeTreeVal opts gro) . s2t) sa
---- CLinearize m -> changeArg (opTS2CommandArg (optLinearizeArgForm opts gro m)) sa

View File

@@ -185,11 +185,11 @@ txtHelpFile =
"\n HINT: see GF language specification for the syntax of Pattern and Term." ++
"\n You can also copy and past parsing results." ++
"\n options: " ++
"\n -table show parameters" ++
"\n -struct bracketed form" ++
"\n -record record, i.e. explicit GF concrete syntax term" ++
"\n -all show all forms and variants" ++
"\n -multi linearize to all languages (the other options don't work)" ++
"\n -table show parameters (not compatible with -record, -all)" ++
"\n -record record, i.e. explicit GF concrete syntax term (not compatible with -table, -all)" ++
"\n -all show all forms and variants (not compatible with -record, -table)" ++
"\n -multi linearize to all languages (can be combined with the other options)" ++
"\n flags:" ++
"\n -lang linearize in this grammar" ++
"\n -number give this number of forms at most" ++
@@ -243,6 +243,9 @@ txtHelpFile =
"\n options:" ++
"\n -c compare to existing xml-formatted treebank" ++
"\n -trees return the trees of the treebank" ++
"\n -all show all linearization alternatives (branches and variants)" ++
"\n -table show tables of linearizations with parameters" ++
"\n -record show linearization records" ++
"\n -xml wrap the treebank (or comparison results) with XML tags" ++
"\n -mem write the treebank in memory instead of a file TODO" ++
"\n examples:" ++

View File

@@ -186,7 +186,7 @@ optionsOfCommand co = case co of
CGenerateRandom -> both "cf prob" "cat lang number depth atoms noexpand doexpand"
CGenerateTrees -> both "metas" "atoms depth alts cat lang number noexpand doexpand"
CPutTerm -> flags "transform number"
CTreeBank -> opts "c xml trees"
CTreeBank -> opts "c xml trees all table record"
CLookupTreebank -> both "assocs raw strings trees" "treebank"
CWrapTerm _ -> opts "c"
CApplyTransfer _ -> flags "lang transfer"

View File

@@ -30,7 +30,7 @@ module GF.UseGrammar.Treebank (
) where
import GF.Compile.ShellState
import GF.UseGrammar.Linear (linTree2string)
import GF.UseGrammar.Linear -- (linTree2string)
import GF.UseGrammar.Custom
import GF.UseGrammar.GetTree (string2tree)
import GF.Grammar.TypeCheck (annotate)
@@ -38,7 +38,7 @@ import GF.Canon.CMacros (noMark)
import GF.Grammar.Grammar (Trm)
import GF.Grammar.MMacros (exp2tree)
import GF.Grammar.Macros (zIdent)
import GF.Grammar.PrGrammar (prt_)
import GF.Grammar.PrGrammar (prt_,prt)
import GF.Grammar.Values (tree2exp)
import GF.Data.Operations
import GF.Infra.Option
@@ -47,6 +47,7 @@ import GF.Infra.UseIO
import qualified GF.Grammar.Abstract as A
import qualified Data.Map as M
import qualified Data.Set as S
import Control.Monad (liftM)
-- Generate a treebank with a multilingual grammar. AR 8/2/2006
-- (c) Aarne Ranta 2006 under GNU GPL
@@ -95,7 +96,7 @@ mkMultiTreebank opts sh com trees = putInXML opts "treebank" comm (concatMap mkI
mkItem(t,i)= putInXML opts "item" (cat i) (mkTree t ++ concatMap (mkLin t) langs)
-- mkItem(t,i)= putInXML opts "item" (cat i) (mkTree t >>mapM_ (mkLin t) langs)
mkTree t = putInXML opts "tree" [] (puts $ showTree t)
mkLin t lg = putInXML opts "lin" (lang lg) (puts $ linearize sh lg t)
mkLin t lg = putInXML opts "lin" (lang lg) (puts $ linearize opts sh lg t)
langs = [prt_ l | l <- allLanguages sh]
comm = "" --- " command=" ++ show com +++ "abstract=" ++ show abstr
@@ -110,7 +111,7 @@ mkUniTreebank :: Options -> ShellState -> Language -> [A.Tree] -> Treebank
mkUniTreebank opts sh lg trees = M.fromListWith (++) [(lin t, [prt_ t]) | t <- trees]
where
lang = prt_ lg
lin t = linearize sh lang t
lin t = linearize opts sh lang t
-- reads a treebank and linearizes its trees again, printing all differences
testMultiTreebank :: Options -> ShellState -> String -> Res
@@ -120,7 +121,7 @@ testMultiTreebank opts sh = putInXML opts "testtreebank" [] .
where
testOne (e,lang,str0) = do
let tr = annot gr e
let str = linearize sh lang tr
let str = linearize opts sh lang tr
if str == str0 then ret else putInXML opts "diff" [] $ concat [
putInXML opts "tree" [] (puts $ showTree tr),
putInXML opts "old" (" lang=" ++ show (prt_ (zIdent lang))) $ puts str0,
@@ -198,11 +199,18 @@ tagXML s = "<" ++ s ++ ">"
--- these handy functions are borrowed from EmbedAPI
linearize mgr lang =
untok .
linTree2string noMark (canModules mgr) (zIdent lang)
where
sgr = stateGrammarOfLangOpt False mgr (zIdent lang)
untok = customOrDefault (stateOptions sgr) useUntokenizer customUntokenizer sgr
linearize opts mgr lang = lin where
sgr = stateGrammarOfLangOpt False mgr zlang
cgr = canModules mgr
zlang = zIdent lang
untok = customOrDefault (addOptions opts (stateOptions sgr)) useUntokenizer customUntokenizer sgr
lin
| oElem showRecord opts = err id id . liftM prt . linearizeNoMark cgr zlang
| oElem tableLin opts =
err id id . liftM (unlines . map untok . prLinTable True) . allLinTables cgr zlang
| oElem showAll opts =
err id id . liftM (unlines . map untok . prLinTable False) . allLinTables cgr zlang
| otherwise = untok . linTree2string noMark cgr zlang
showTree t = prt_ $ tree2exp t

View File

@@ -156,11 +156,11 @@ l, linearize: l PattList? Tree
HINT: see GF language specification for the syntax of Pattern and Term.
You can also copy and past parsing results.
options:
-table show parameters
-struct bracketed form
-record record, i.e. explicit GF concrete syntax term
-all show all forms and variants
-multi linearize to all languages (the other options don't work)
-table show parameters (not compatible with -record, -all)
-record record, i.e. explicit GF concrete syntax term (not compatible with -table, -all)
-all show all forms and variants (not compatible with -record, -table)
-multi linearize to all languages (can be combined with the other options)
flags:
-lang linearize in this grammar
-number give this number of forms at most
@@ -214,6 +214,9 @@ tb, tree_bank: tb
options:
-c compare to existing xml-formatted treebank
-trees return the trees of the treebank
-all show all linearization alternatives (branches and variants)
-table show tables of linearizations with parameters
-record show linearization records
-xml wrap the treebank (or comparison results) with XML tags
-mem write the treebank in memory instead of a file TODO
examples: