diff --git a/src/www/minibar/gf-web-api-examples.html b/src/www/minibar/gf-web-api-examples.html index df6db0756..ae1a69c9e 100644 --- a/src/www/minibar/gf-web-api-examples.html +++ b/src/www/minibar/gf-web-api-examples.html @@ -107,10 +107,10 @@ full API.
[{"tree":"Pred (That Pizza) (Very Boring)"}]
// Linearize a syntax tree
server.linearize({tree:"Pred (That Pizza) (Very Boring)",to:"FoodsEng"},callback) -
http://localhost:41296/grammars/Foods.pgf?command=linearize&tree=Pred+(That+Pizza)+(Very+Boring)&to=FoodsEng +
http://localhost:41296/grammars/Foods.pgf?command=linearize&tree=Pred+(That+Pizza)+(Very+Boring)&to=FoodsEng
[{"to":"FoodsEng","text":"that pizza is very boring"}]
server.linearize({tree:"Pred (That Pizza) (Very Boring)"},callback) -
http://localhost:41296/grammars/Foods.pgf?command=linearize&tree=Pred+(That+Pizza)+(Very+Boring) +
http://localhost:41296/grammars/Foods.pgf?command=linearize&tree=Pred+(That+Pizza)+(Very+Boring)
[{"to":"FoodsBul","text":"онази пица е много еднообразна"}, {"to":"FoodsEng","text":"that pizza is very boring"}, {"to":"FoodsFin","text":"tuo pizza on erittäin tylsä"}, @@ -119,7 +119,7 @@ full API. ]
// Parse a string
server.parse({from:"FoodsEng",input:"that pizza is very boring"},callback) -
http://localhost:41296/grammars/Foods.pgf?command=parse&input=that+pizza+is+very+boring&from=FoodsEng +
http://localhost:41296/grammars/Foods.pgf?command=parse&input=that+pizza+is+very+boring&from=FoodsEng
[{"from":"FoodsEng", "brackets":{"cat":"Comment","fid":10,"index":0,"children":[{"cat":"Item","fid":7,"index":0,"children":[{"token":"that"},{"cat":"Kind","fid":6,"index":0,"children":[{"token":"pizza"}]}]},{"token":"is"},{"cat":"Quality","fid":9,"index":0,"children":[{"token":"very"},{"cat":"Quality","fid":8,"index":0,"children":[{"token":"boring"}]}]}]}, "trees":["Pred (That Pizza) (Very Boring)"]}] @@ -128,7 +128,7 @@ full API.
...
// Translate to one language
server.translate({input:"that pizza is very boring", from:"FoodsEng", to:"FoodsSwe"}, callback) -
http://localhost:41296/grammars/Foods.pgf?command=translate&input=that+pizza+is+very+boring&from=FoodsEng&to=FoodsSwe +
http://localhost:41296/grammars/Foods.pgf?command=translate&input=that+pizza+is+very+boring&from=FoodsEng&to=FoodsSwe
[{"from":"FoodsEng", "brackets":{"cat":"Comment","fid":10,"index":0,"children":[{"cat":"Item","fid":7,"index":0,"children":[{"token":"that"},{"cat":"Kind","fid":6,"index":0,"children":[{"token":"pizza"}]}]},{"token":"is"},{"cat":"Quality","fid":9,"index":0,"children":[{"token":"very"},{"cat":"Quality","fid":8,"index":0,"children":[{"token":"boring"}]}]}]}, "translations": @@ -138,25 +138,33 @@ full API. "text":"den där pizzan är mycket tråkig"}]}]}]
// Get completions (what words could come next)
server.complete({from:"FoodsEng",input:"that pizza is very "},callback) -
http://localhost:41296/grammars/Foods.pgf?command=complete&input=that+pizza+is+very+&from=FoodsEng +
http://localhost:41296/grammars/Foods.pgf?command=complete&input=that+pizza+is+very+&from=FoodsEng
[{"from":"FoodsEng", "brackets":{"cat":"_","fid":0,"index":0,"children":[{"cat":"Item","fid":7,"index":0,"children":[{"token":"that"},{"cat":"Kind","fid":6,"index":0,"children":[{"token":"pizza"}]}]},{"token":"is"},{"token":"very"}]}, "completions":["boring","delicious","expensive","fresh","Italian","very","warm"], "text":""}]
// Get info about a category in the abstract syntax
server.browse({id:"Kind"},callback) -
http://localhost:41296/grammars/Foods.pgf?command=browse&id=Kind&format=json +
http://localhost:41296/grammars/Foods.pgf?command=browse&id=Kind&format=json
{"def":"cat Kind", "producers":["Cheese","Fish","Mod","Pizza","Wine"], "consumers":["Mod","That","These","This","Those"]}
// Get info about a function in the abstract syntax
server.browse({id:"This"},callback) -
http://localhost:41296/grammars/Foods.pgf?command=browse&id=This&format=json +
http://localhost:41296/grammars/Foods.pgf?command=browse&id=This&format=json
{"def":"fun This : Kind -> Item","producers":[],"consumers":[]} +
// Convert an abstract syntax tree to JSON +
server.pgf_call("abstrjson",{tree:"Pred (That Pizza) (Very Boring)"},callback) + +
http://localhost:41296/grammars/Foods.pgf?command=abstrjson&tree=Pred+(That+Pizza)+(Very+Boring) +
{"fun":"Pred","fid":4, + "children":[{"fun":"That","fid":1, + "children":[{"fun":"Pizza","fid":0}]}, + {"fun":"Very","fid":3, + "children":[{"fun":"Boring","fid":2}]}]}
- Last modified: Tue Apr 10 15:08:14 CEST 2012 +Last modified: Sat Nov 17 12:53:47 CET 2012
TH
- \ No newline at end of file