@@ -22,6 +22,7 @@ import GF.Infra.SIO
2222import GF.Command.Abstract
2323import GF.Command.CommandInfo
2424import GF.Command.CommonCommands
25+ import qualified GF.Command.CommonCommands as Common
2526import GF.Text.Clitics
2627import GF.Quiz
2728
@@ -166,14 +167,15 @@ pgfCommands = Map.fromList [
166167 synopsis = " generate random trees in the current abstract syntax" ,
167168 syntax = " gr [-cat=CAT] [-number=INT]" ,
168169 examples = [
169- mkEx " gr -- one tree in the startcat of the current grammar" ,
170- mkEx " gr -cat=NP -number=16 -- 16 trees in the category NP" ,
171- mkEx " gr -lang=LangHin,LangTha -cat=Cl -- Cl, both in LangHin and LangTha" ,
172- mkEx " gr -probs=FILE -- generate with bias" ,
173- mkEx " gr (AdjCN ? (UseN ?)) -- generate trees of form (AdjCN ? (UseN ?))"
170+ mkEx $ " gr -- one tree in the startcat of the current grammar, up to depth " ++ Common. default_depth_str,
171+ mkEx " gr -cat=NP -number=16 -- 16 trees in the category NP" ,
172+ mkEx " gr -cat=NP -depth=2 -- one tree in the category NP, up to depth 2" ,
173+ mkEx " gr -lang=LangHin,LangTha -cat=Cl -- Cl, both in LangHin and LangTha" ,
174+ mkEx " gr -probs=FILE -- generate with bias" ,
175+ mkEx " gr (AdjCN ? (UseN ?)) -- generate trees of form (AdjCN ? (UseN ?))"
174176 ],
175177 explanation = unlines [
176- " Generates a list of random trees, by default one tree." ,
178+ " Generates a list of random trees, by default one tree up to depth " ++ Common. default_depth_str ++ " ." ,
177179 " If a tree argument is given, the command completes the Tree with values to" ,
178180 " all metavariables in the tree. The generation can be biased by probabilities," ,
179181 " given in a file in the -probs flag."
@@ -182,13 +184,13 @@ pgfCommands = Map.fromList [
182184 (" cat" ," generation category" ),
183185 (" lang" ," uses only functions that have linearizations in all these languages" ),
184186 (" number" ," number of trees generated" ),
185- (" depth" ," the maximum generation depth" ),
187+ (" depth" ," the maximum generation depth (default: " ++ Common. default_depth_str ++ " ) " ),
186188 (" probs" , " file with biased probabilities (format 'f 0.4' one by line)" )
187189 ],
188190 exec = getEnv $ \ opts arg (Env pgf mos) -> do
189191 pgf <- optProbs opts (optRestricted opts pgf)
190192 gen <- newStdGen
191- let dp = valIntOpts " depth" 4 opts
193+ let dp = valIntOpts " depth" Common. default_depth opts
192194 let ts = case mexp (toExprs arg) of
193195 Just ex -> generateRandomFromDepth gen pgf ex (Just dp)
194196 Nothing -> generateRandomDepth gen pgf (optType pgf opts) (Just dp)
@@ -199,25 +201,25 @@ pgfCommands = Map.fromList [
199201 synopsis = " generates a list of trees, by default exhaustive" ,
200202 explanation = unlines [
201203 " Generates all trees of a given category. By default, " ,
202- " the depth is limited to 4 , but this can be changed by a flag." ,
204+ " the depth is limited to " ++ Common. default_depth_str ++ " , but this can be changed by a flag." ,
203205 " If a Tree argument is given, the command completes the Tree with values" ,
204206 " to all metavariables in the tree."
205207 ],
206208 flags = [
207209 (" cat" ," the generation category" ),
208- (" depth" ," the maximum generation depth" ),
210+ (" depth" ," the maximum generation depth (default: " ++ Common. default_depth_str ++ " ) " ),
209211 (" lang" ," excludes functions that have no linearization in this language" ),
210212 (" number" ," the number of trees generated" )
211213 ],
212214 examples = [
213- mkEx " gt -- all trees in the startcat, to depth 4 " ,
214- mkEx " gt -cat=NP -number=16 -- 16 trees in the category NP" ,
215- mkEx " gt -cat=NP -depth=2 -- trees in the category NP to depth 2" ,
216- mkEx " gt (AdjCN ? (UseN ?)) -- trees of form (AdjCN ? (UseN ?))"
215+ mkEx $ " gt -- all trees in the startcat, to depth " ++ Common. default_depth_str ,
216+ mkEx " gt -cat=NP -number=16 -- 16 trees in the category NP" ,
217+ mkEx " gt -cat=NP -depth=2 -- trees in the category NP to depth 2" ,
218+ mkEx " gt (AdjCN ? (UseN ?)) -- trees of form (AdjCN ? (UseN ?))"
217219 ],
218220 exec = getEnv $ \ opts arg (Env pgf mos) -> do
219221 let pgfr = optRestricted opts pgf
220- let dp = valIntOpts " depth" 4 opts
222+ let dp = valIntOpts " depth" Common. default_depth opts
221223 let ts = case toExprs arg of
222224 [] -> generateAllDepth pgfr (optType pgf opts) (Just dp)
223225 es -> concat [generateFromDepth pgfr e (Just dp) | e <- es]
@@ -547,7 +549,7 @@ pgfCommands = Map.fromList [
547549 " which is processed by dot (graphviz) and displayed by the program indicated" ,
548550 " by the view flag. The target format is png, unless overridden by the" ,
549551 " flag -format. Results from multiple trees are combined to pdf with convert (ImageMagick)." ,
550- " See also 'vp -showdep' for another visualization of dependencies."
552+ " See also 'vp -showdep' for another visualization of dependencies."
551553 ],
552554 exec = getEnv $ \ opts arg (Env pgf mos) -> do
553555 let absname = abstractName pgf
@@ -760,7 +762,7 @@ pgfCommands = Map.fromList [
760762 [] -> [parse_ pgf lang (optType pgf opts) (Just dp) s | lang <- optLangs pgf opts]
761763 open_typs -> [parseWithRecovery pgf lang (optType pgf opts) open_typs (Just dp) s | lang <- optLangs pgf opts]
762764 where
763- dp = valIntOpts " depth" 4 opts
765+ dp = valIntOpts " depth" Common. default_depth opts
764766
765767 fromParse opts = foldr (joinPiped . fromParse1 opts) void
766768
@@ -800,9 +802,9 @@ pgfCommands = Map.fromList [
800802 _ | isOpt " tabtreebank" opts ->
801803 return $ concat $ intersperse " \t " $ (showExpr [] t) :
802804 [s | lang <- optLangs pgf opts, s <- linear pgf opts lang t]
803- _ | isOpt " chunks" opts -> map snd $ linChunks pgf opts t
805+ _ | isOpt " chunks" opts -> map snd $ linChunks pgf opts t
804806 _ -> [s | lang <- optLangs pgf opts, s<- linear pgf opts lang t]
805- linChunks pgf opts t =
807+ linChunks pgf opts t =
806808 [(lang, unwords (intersperse " <+>" (map (unlines . linear pgf opts lang) (treeChunks t)))) | lang <- optLangs pgf opts]
807809
808810 linear :: PGF -> [Option ] -> CId -> Expr -> [String ]
@@ -1006,13 +1008,13 @@ viewLatex view name grphs = do
10061008 restrictedSystem $ " pdflatex " ++ texfile
10071009 restrictedSystem $ view ++ " " ++ pdffile
10081010 return void
1009-
1011+
10101012---- copied from VisualizeTree ; not sure about proper place AR Nov 2015
10111013latexDoc :: [String ] -> String
10121014latexDoc body = unlines $
10131015 " \\ batchmode"
10141016 : " \\ documentclass{article}"
1015- : " \\ usepackage[utf8]{inputenc}"
1017+ : " \\ usepackage[utf8]{inputenc}"
10161018 : " \\ begin{document}"
10171019 : spaces body
10181020 ++ [" \\ end{document}" ]
0 commit comments