From 9532a34a2a79196abd51dfe32b6cddb361a48368 Mon Sep 17 00:00:00 2001 From: hallgren Date: Thu, 25 Nov 2010 18:30:30 +0000 Subject: [PATCH] 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"}] --- src/server/PGFService.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/server/PGFService.hs b/src/server/PGFService.hs index 7269c1eee..fee8c766c 100644 --- a/src/server/PGFService.hs +++ b/src/server/PGFService.hs @@ -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 =