summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2010-11-25 18:30:30 +0000
committerhallgren <hallgren@chalmers.se>2010-11-25 18:30:30 +0000
commit75ad59b1217e4b81d19fed6eadf4fc80d3ebd2f1 (patch)
treea407071cf99ca2b8eccadf3387f2062be5db119a /src
parent243a0b3659f85b27af2bb5e0c884aca0c720c8a7 (diff)
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"}]
Diffstat (limited to 'src')
-rw-r--r--src/server/PGFService.hs11
1 files 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 =