1
0
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:
hallgren
2010-11-25 18:30:30 +00:00
parent 0460ed2d8b
commit 9532a34a2a

View File

@@ -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 =