Page 1
The GF Cloud: web Apps and APIs
GF Summer School 2017
Thomas Hallgren
Page 2
Where is the GF cloud
On our server
cloud.grammaticalframework.org
On your on computer
Download and install GF (
cabal install gf -fserver
)
run
gf -server
Open it your browser
Page 3
What is in the GF cloud
Minibar
Syntax editor
Simple Translation Tool
Translation Quiz
GF online editor simple multilingual grammars
Wide Coverage Translation Demo (requires App16.pgf)
Some documentation
Page 4
Some other web applications
Available from
www.grammaticalframework.org/demos
.
Tourist Phrasebook, Mathbar (from MOLTO)
Phrasomatic
Syllogisms (JavaScript + Haskell + ...)
Multilingual Wiki
Numeral translator, Letter editor (older, Java applets)
Page 5
Using GF grammars in web applications
Compiling grammars to PGF (Portable Grammar Format) files
Using the PGF web API
Page 6
The Portable Grammar Format
GF compiles grammar source files into PGF files (Portable Grammat Format).
PGF files can be used with the
PGF run-time library
.
Example:
gf -make FoodsEng.gf FoodsSwe.gf
Creates
Foods.pgf
Page 7
PGF run-time libraries
PGF (Haskell implementation)
PGF2 (C implementation)
Haskell binding
Java binding
Python binding
.NET binding
Page 8
PGF web service API
For client-side web applications in JavaScript
For (server-side) applications in other programming languages
Operations:
list available grammars,
parse, linearize, translate,
completion, random generation, ...
Access to both PGF and PGF2
c-parse, c-linearize, c-translate, ...
Page 9
PGF JavaScript library
PGF service access
pgf_online.js
,
support.js
Documentation:
PGF web API examples
gftranslate.js
Page 10
User interface components
minibar_input.js
: user input with magnets and completion
minibar_translations.js
: display translations
minibar.js
: complete Minibar web app
syntax-editor/editor.js
: syntax tree editor
minibar_support.js
,
support.js
: auxiliary functions
Documentation:
Minibar API
Page 11
Running the PGF service on your own computer
GF server mode
Standalone HTTP Server included in GF distributions
(>=3.2)
gf -server
This is GF version 3.9. Document root = .../lib/gf-3.9/share/www Starting HTTP server, open http://localhost:41296/ in your web browser.
Copy your
.pgf
files to
grammars
under the document root shown when starting
gf -server
This gives you the same web apps and services as provided on cloud.grammaticalframework.org.
Page 12
Web applications without a web server
Translating grammars to JavaScript, example:
gf -make --output-format=js FoodEng.gf FoodIta.gf
Used in
Muste
The
Multilingual Restaurant Wiki
Also uses a server-side database
Limited functionality
Currently not maintained?
Page 13
The End
Questions?
More info
GF book
(Chapter 7: Embedded grammars and code generation)
www.grammaticalframework.org
(main GF web site)
cloud.grammaticalframework.org
(demo apps and web API documentation)
PGF run-time library in Haskell
PGF run-time library in C
(old page)
Python
binding
Page 14
Extra
Server-side application programming with GF grammars
The wide-coverage translation web demo