mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-24 03:52:50 -06:00
command l -list ; fixed mq to work with the new tabularLinearizes
This commit is contained in:
@@ -392,8 +392,9 @@ allCommands cod env@(pgf, mos) = Map.fromList [
|
|||||||
],
|
],
|
||||||
exec = \opts -> return . fromStrings . map (optLin opts),
|
exec = \opts -> return . fromStrings . map (optLin opts),
|
||||||
options = [
|
options = [
|
||||||
("all","show all forms and variants"),
|
("all","show all forms and variants, one by line (cf. l -list)"),
|
||||||
("bracket","show tree structure with brackets and paths to nodes"),
|
("bracket","show tree structure with brackets and paths to nodes"),
|
||||||
|
("list","show all forms and variants, comma-separated on one line (cf. l -all)"),
|
||||||
("multi","linearize to all languages (default)"),
|
("multi","linearize to all languages (default)"),
|
||||||
("table","show all forms labelled by parameters"),
|
("table","show all forms labelled by parameters"),
|
||||||
("treebank","show the tree and tag linearizations with language names")
|
("treebank","show the tree and tag linearizations with language names")
|
||||||
@@ -870,8 +871,12 @@ allCommands cod env@(pgf, mos) = Map.fromList [
|
|||||||
|
|
||||||
linear :: [Option] -> CId -> Expr -> String
|
linear :: [Option] -> CId -> Expr -> String
|
||||||
linear opts lang = let unl = unlex opts lang in case opts of
|
linear opts lang = let unl = unlex opts lang in case opts of
|
||||||
_ | isOpt "all" opts -> unlines . concat . intersperse [[]] . map (map (unl . snd)) . tabularLinearizes pgf lang
|
_ | isOpt "all" opts -> unlines . concat . intersperse [[]] .
|
||||||
_ | isOpt "table" opts -> unlines . concat . intersperse [[]] . map (map (\(p,v) -> p+++":"+++unl v)) . tabularLinearizes pgf lang
|
map (map (unl . snd)) . tabularLinearizes pgf lang
|
||||||
|
_ | isOpt "list" opts -> commaList . concat . intersperse [[]] .
|
||||||
|
map (map (unl . snd)) . tabularLinearizes pgf lang
|
||||||
|
_ | isOpt "table" opts -> unlines . concat . intersperse [[]] .
|
||||||
|
map (map (\(p,v) -> p+++":"+++unl v)) . tabularLinearizes pgf lang
|
||||||
_ | isOpt "bracket" opts -> unlines . markLinearizes pgf lang
|
_ | isOpt "bracket" opts -> unlines . markLinearizes pgf lang
|
||||||
_ -> unl . linearize pgf lang
|
_ -> unl . linearize pgf lang
|
||||||
|
|
||||||
@@ -883,6 +888,9 @@ allCommands cod env@(pgf, mos) = Map.fromList [
|
|||||||
Just le -> chunks ',' le
|
Just le -> chunks ',' le
|
||||||
_ -> []
|
_ -> []
|
||||||
|
|
||||||
|
commaList [] = []
|
||||||
|
commaList ws = concat $ head ws : map (", " ++) (tail ws)
|
||||||
|
|
||||||
-- Proposed logic of coding in unlexing:
|
-- Proposed logic of coding in unlexing:
|
||||||
-- - If lang has no coding flag, or -to_utf8 is not in opts, just opts are used.
|
-- - If lang has no coding flag, or -to_utf8 is not in opts, just opts are used.
|
||||||
-- - If lang has flag coding=utf8, -to_utf8 is ignored.
|
-- - If lang has flag coding=utf8, -to_utf8 is ignored.
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ morphologyList pgf ig typ number = do
|
|||||||
ts <- generateRandom pgf typ >>= return . take (max 1 number)
|
ts <- generateRandom pgf typ >>= return . take (max 1 number)
|
||||||
gen <- newStdGen
|
gen <- newStdGen
|
||||||
let ss = map (tabularLinearizes pgf ig) ts
|
let ss = map (tabularLinearizes pgf ig) ts
|
||||||
let size = length (head ss)
|
let size = length (head (head ss))
|
||||||
let forms = take number $ randomRs (0,size-1) gen
|
let forms = take number $ randomRs (0,size-1) gen
|
||||||
return [(snd (head pws0) +++ fst (pws0 !! i), ws) |
|
return [(snd (head pws0) +++ fst (pws0 !! i), ws) |
|
||||||
(pwss@(pws0:_),i) <- zip ss forms, let ws = map (\pws -> snd (pws !! i)) pwss]
|
(pwss@(pws0:_),i) <- zip ss forms, let ws = map (\pws -> snd (pws !! i)) pwss]
|
||||||
|
|||||||
Reference in New Issue
Block a user