forked from GitHub/gf-core
pgf-server: more useful JSON output from lineraizeAll
Example: Request: http://www.grammaticalframework.org:41296/grammars/Quiz.pgf?command=linearizeAll&tree=Run+YouPl Response: [{"to":"QuizEng","texts":["you run"]}, {"to":"QuizSwe","texts":["ni l??per","ni springer"]}] Compared to the old command linearize: Request: http://www.grammaticalframework.org:41296/grammars/Quiz.pgf?command=linearize&tree=Run+YouPl' Response: [{"to":"QuizEng","text":"you run"}, {"to":"QuizSwe","text":"ni l??per"}]
This commit is contained in:
@@ -266,12 +266,15 @@ doComplete pgf input mcat mfrom mlimit = showJSON $ map toJSObject
|
||||
cat = fromMaybe (PGF.startCat pgf) mcat
|
||||
|
||||
doLinearize :: PGF -> PGF.Tree -> Maybe PGF.Language -> JSValue
|
||||
doLinearize pgf tree mto = showJSON $ map toJSObject
|
||||
[[("to", PGF.showLanguage to),("text",text)] | (to,text) <- linearize' pgf mto tree]
|
||||
doLinearize pgf tree mto = showJSON $
|
||||
[toJSObject [("to", PGF.showLanguage to),("text",text)]
|
||||
| (to,text) <- linearize' pgf mto tree]
|
||||
|
||||
doLinearizes :: PGF -> PGF.Tree -> Maybe PGF.Language -> JSValue
|
||||
doLinearizes pgf tree mto = showJSON $ map toJSObject
|
||||
[("to", PGF.showLanguage to):[("text",text) | text <- texts] | (to,texts) <- linearizes' pgf mto tree]
|
||||
doLinearizes pgf tree mto = showJSON $
|
||||
[toJSObject [("to", showJSON $ PGF.showLanguage to),
|
||||
("texts",showJSON texts)]
|
||||
| (to,texts) <- linearizes' pgf mto tree]
|
||||
|
||||
doRandom :: PGF -> Maybe PGF.Type -> Maybe Int -> Maybe Int -> Maybe PGF.Language -> IO JSValue
|
||||
doRandom pgf mcat mdepth mlimit mto =
|
||||
|
||||
Reference in New Issue
Block a user