1
0
forked from GitHub/gf-core
Commit Graph

283 Commits

Author SHA1 Message Date
hallgren
622ab0b44c Fix build problem in PGFService.hs when configured without c-runtime 2014-04-08 20:45:54 +00:00
hallgren
29efca71cb PGF web service: add lexer support
The PGF web API commands parse, translate, translategroup, c-parse and
c-translate now support a lexer parameter. Possible values are "text",
"code" and "mixed".

This is used in the Wide Coverage Demo App to save one server roundtrip.
2014-04-08 16:10:33 +00:00
hallgren
4018073bdb PGFService.hs: adapt to changes in the Haskell binding to the C run-time system
Parse errors used to cause crashes, but they are now handled and reported.
2014-04-04 12:28:00 +00:00
hallgren
b061d59044 gf -server: add a command to manually flush the PGF cache
This can be used if the cloud service seems slow, but it would probably
be better to automatically expire unused PGFs from the cache after some time.
2014-03-19 16:15:05 +00:00
john.j.camilleri
f4be97c152 Fix typo in PGFService: "incomlete" 2014-03-12 12:45:32 +00:00
hallgren
44ee072331 Work on web api & apps based on the C run-time system
+ PGFService.hs: add command c-grammar, include probability in parse results
+ js/gftranslation.js: add start position and limit parameters, return more
  info to applications
+ Simple Translator: show two wide coverage translations
+ Wide coverage demo: show parse tree and probability (intended as grammar
  debugging aids)
2014-02-11 16:43:29 +00:00
hallgren
60980d1617 Fix broken C runtime support in gf.cabal and PGFService.hs
Also add PGF service command c-flush to explicitly flush cached parse results
from memory.
2014-02-10 16:04:40 +00:00
hallgren
dbd68b987e gf-server.cabal: flag to include C run-time support in the FastCGI PGF service 2014-01-31 16:11:41 +00:00
hallgren
06bb2a1dad PGFService.hs: fix a type ambiguity when compiling without C run-time support 2014-01-27 16:46:48 +00:00
hallgren
b3251f402d PGFService.hs: add a cache for C run-time parse result and a start offset parameter
Cached parse results are discarded when they have been unused for 10 minutes.
2014-01-27 16:32:09 +00:00
hallgren
9d71ffc831 Optionally include C run-time support
If the C run-time library is compiled and installed on your system, you can now
do 'cabal configure -fc-runtime' to get the following extras:
  + The haskell binding to the C run-time library will be included in the
    PGF library (so you can import it in Haskell applications).
    Documentation on the new modules will be included when you run
    'cabal haddock'.
  + The new command 'pgf-shell', implemented on top of haskell binding to
    the C run-time system.
  + Three new commands in the web API: c-parse, c-linearize and
    c-translate. Their interfaces are similar to the corresponding commands
    without the "c-" prefix, but they should be considered preliminary.
2014-01-20 17:06:11 +00:00
hallgren
e9e919e6e3 src/server/gf-server.cabal: compile it as a common library + executables 2013-12-17 15:55:14 +00:00
kr.angelov
a4194501fe linref is now used by the linearizer. The visible change is that the 'l' command in the shell now can linearize discontinuous phrases 2013-10-30 14:42:29 +00:00
hallgren
9410c6b141 Functions merge trees into tries in the GF Shell and the PGF web service
* In the shell, the new command tt (to_trie) merges a list of trees into a
  trie and prints it in a readable way, where unique subtrees are marked with
  a "*" and alternative subtrees are marked with numbers.
* In the PGF web service, adding the parameter trie=yes to the parse and
  translate commands augments the JSON output with a trie.

Example to try in the shell:

	Phrasebook> p -lang=Eng "your son waits for you" | tt
2013-10-24 17:29:02 +00:00
hallgren
27da46a79d Cloud & PGF service: use Content-Type application/json for JSON output
This is in accordance with RFC 4627. http://tools.ietf.org/html/rfc4627
Use application/javascript for JSONP output.
2013-07-29 16:05:54 +00:00
hallgren
e07a74df01 Allow cross origin requests to GF cloud & PGF services
By adding a header

	Access-Control-Allow-Origin: *

to the HTTP responses, web browsers are informed that it is OK to call the
services from web pages hosted on other sites.

This is apparently supported in most modern browsers, so it should no longer
be necessary to resort to JSONP.

See https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS
2013-07-25 16:04:43 +00:00
hallgren
fe79e8cd25 gf-server.cabal: same changes as in gf.cabal for ghc-7.6 compatibility 2013-07-15 17:07:51 +00:00
hallgren
bdfd663e91 Fix UTF-8 decoding problem in gf -server
The package network-2.4.1.1 thoughlessly introduced a backward incompatible
change to the function Network.URI.unEscapeString, see

    f2168b1f89

This also affects the function Network.Shed.Httpd.queryToArguments, which is
used in GFServer.hs.

To remain compatible with older and newer versions of the network package,
we need to stay clear of queryToArguments and unEscapeString. A replacement
function has been added to server/URLEncoding.hs.
2013-06-13 08:23:48 +00:00
hallgren
5fe680c837 PGF service: apply the token binding operator &+ to all linearizations
The &+ operator is now consistently eliminated from the output of commmands
that produce linearizations. Before, only the commands translate and
translategroup did this.
2013-04-24 18:32:53 +00:00
hallgren
08046137cb PGF web API: command=abstrtree not supports the nocat and nofun options 2013-03-28 15:57:17 +00:00
hallgren
1ff78dae97 PGF web API: add comand linearizeTable
The new command linearizeTable outputs linearizations as tables containing all
variants and forms, labelled by parameters
2013-03-27 16:31:52 +00:00
hallgren
1962574941 PGF service: support all parse tree visualziation options in the web API
The new options are

  * noleaves, nofun, nocat (booleans, false by default)
  * nodefont, leaffont, nodecolor, leafcolor, nodeedgestyle, leafedgestyle
    (strings, empty by default)
2013-03-26 14:17:24 +00:00
hallgren
07f958a9b7 PGF web API: add 'to' parameter to the 'alignment' command
Word alignment diagrams can now be restricted to a subset of the languages
supported by the grammar.
2013-03-13 15:56:03 +00:00
hallgren
d4fc60f260 PGF web API: generalize the 'to' parameter to accept a list of languages
Some commands (linearize, linearizeAll, random, generate, translate and
translategroup) by default produce output in all languages supported by the
grammar and the 'to' parameter could be used to restrict output to a single
language. Now you can restrict the output to a list of languages. Languages
should be separated by spaces.

Also removed an unnecessary LANGUAGE pragma and reduced code verbosity.
2013-03-13 15:25:28 +00:00
Sergei Trofimovich
0173b5f4ff ghc-7.6: allow directory-1.2
Get rid of old-time depend (and ClockTime in favour of UTCTime).
time-compat helps to retain backward compatibility with directory-1.1
and lower.
2013-03-09 21:38:43 +00:00
Sergei Trofimovich
576b19aab5 ghc-7.6: fix src/server/PGFService.hs (use catch from base-4 Control.Exception) 2013-03-09 21:38:14 +00:00
john.j.camilleri
3d5d424fef Add fun/cat printnames to PGF web service
This is accessible vis the `browse` command, by adding the flag `printnames`
e.g.: .../Letter.pgf?command=browse&id=Recipient&format=json&printnames=1
2013-01-18 09:39:50 +00:00
hallgren
f2751ff9e1 Fixes for minibar offline
Tested it in Firefox 18 (which has the new Ionmonkey JavaScript engine).
Still get stack overflows.
2013-01-09 16:44:18 +00:00
hallgren
1497fd863a PGF service: new command: download
This makes it possible to download PGF files from servers where the PGF service
is installed.

I am also considering making commmand=download the default instead of
command=grammar.
2013-01-09 13:28:45 +00:00
hallgren
d968503d90 PGFService.hs: code duplication reduction 2012-12-20 00:15:18 +00:00
hallgren
db544b1cc9 PGFService.hs: fix type error caused by change to PGF.graphvizParseTree
Note that some of the graphviz functions have backwards incompatible changes
that might also affect other clients of the PGF run-time library.

Also added graphvizDefaults and export it together with GraphvizOptions from 
the PGF run-time library.
2012-11-22 15:27:16 +00:00
hallgren
ca5b066588 PGF service: command=browse&format=json returns info on all cats and funs
The browse command used to have a required parameter id=... and it returned
info on the given identifier only. Now, if format=json, the id=... parameter
can be omitted to get info on all identifiers at the same time. The returned
JSON structure in this case is

        {cats:{...},funs:{...}}

where the inner objects contain one field per category and function,
respectively, in the same format as when you request info on one category or
function.
2012-11-17 14:22:30 +00:00
hallgren
ca58233bf7 PGF service & minibar: put a limit on the number of parse trees
+ In the PGF web service API, the commands parse, translate and translategroup
  now accept a limit parameter. It limits the number of parse trees returned.
  If no limit is given, the behaviour is backwards compatible, i.e. no limit
  is applied.
+ In minibar, the limit is now set to 25 by default.

This change is based on a suggestion by Kaarel Kaljurand.
2012-09-30 15:35:25 +00:00
hallgren
c2a72daa74 gf-server.cabal: mtl is needed to build pgf-server now 2012-04-02 15:58:21 +00:00
hallgren
1c1679227e PGFService.hs: add web API function "abstrjson"
Abstract syntax trees are represented as strings in the web API. To make them
easier to manipulate in JavaScript, the new function converts them to JSON.

To support structural editing, the nodes are numbered in the same way as in
the bracketed string created when linearizing an abstract syntax tree.

Example: "Pred (That Fish) Fresh" is converted to

	{fun:"Pred",fid:3,
	 children:[{fun:"That",fid:1,
		    children:[{fun:"Fish",fid:0}]},
		   {fun:"Fresh",fid:2}]}
2012-04-02 15:42:43 +00:00
hallgren
07af8988d3 PGF run-time library: function names in BracketedString (experimental)
+ Make room for function names in the BracketedString data structure.
+ Fill in function names when linearizing an abstract syntax tree to a
  BracketedString.
+ Fill in wildCId when it is not obvious what the function is.
+ Function bracketedLinearize: for compatibility with the other linearization
  functions, return Leaf "" instead of error "cannot linearize".
+ Export flattenBracketedString from module PGF.
+ PGFServce: make function names available in the JSON representation of
  BracketedString.
2012-03-18 20:12:26 +00:00
hallgren
7c484aeada PGFService.hs: command=browse can now produce output in JSON format.
To get JSON output, add the parameter format=json. The JSON structure contains
the output from the function PGF.browse.
The default is format=html for backwards compatibility.
2012-03-16 13:55:19 +00:00
hallgren
0722f6f444 PGFService.hs: add output format option to the commands abstrtree, parsetree and alignment
Supported output formats: gv, png, svg.
2012-03-08 11:25:15 +00:00
hallgren
a55588aad5 gf-server.cabal: always build the fastcgi module (pgf-server), lower version requirement on the cgi package
+ The flag fastcgi is removed: building the fastcgi is the main purpose of
  this cabal file again.
+ pgf-http superseded by gf-server, but is still available as an option
+ Require cgi>=3001.7.3 instead of cgi>=3001.8.0.
2012-03-05 16:38:54 +00:00
hallgren
f573d52b43 PGFService.hs bug fix: pattern match failure in doParse
doParse was missing a branch for PGF.ParseIncomplete.
Also introduced the operator .= to simply the code that builds JSON objects.
2012-02-29 16:21:34 +00:00
hallgren
e30eeb4918 src/server/ContentService.hs: fix compilaton problem 2012-02-23 16:46:21 +00:00
hallgren
b8124730b1 pgf-http setup: update path to minibar 2011-10-18 15:35:30 +00:00
hallgren
4c3cc9f176 pgf service: include the start category in grammar info 2011-10-18 14:31:40 +00:00
hallgren
04d2dc757c More functionality in "gf -server" mode
"gf -server" mode now includes PGF service and the services to support
example-based grammar writing. (But gf -server is not quite ready to replace
pgf-http yet...) 

Also bumped GF version number to 3.2.10-darcs
2011-10-10 16:16:16 +00:00
hallgren
623c72ca1d pgf-http: fix a bug that caused "+" to be treaded as " " in PGF service requests URLs.
This was a bug in my workaround for a bug in the httpd-shed package. It
made it impossible to use the glue token "&+" for Turkish input in the minibar,
for example.
2011-08-25 16:58:17 +00:00
hallgren
1fccece30c pgf-service: apply the OpenMath LaTeX function only when linearizing to a
concrete language whose name ends with LaTeX.
This change also avoids duplicating output and, in addition to the linearize
command, applies the transfer also when using the linearizeAll command.
2011-08-24 09:37:55 +00:00
hallgren
ba03db58a4 pgf-service: add Jordis transfer function for OpenMath LaTeX output 2011-08-23 16:25:00 +00:00
hallgren
cf9f1057ed pgf service: external service hook: always format the output as a JSON string 2011-08-22 16:10:56 +00:00
hallgren
d8d80693db pgf service: added a hook for external services
This is really reinventing CGI, people should learn how to write CGI scripts
instead...
TODO: better handling of temporary files
2011-08-22 15:34:44 +00:00
hallgren
e1385da050 gf-server: make pgf-service work the Apache mod_fastcgi
pgf-service now appears to works with Apache mod_fastcgi (under Mac OS X) in
addition to lighttpd.

One difference appears to be that while lighttpd passes the name of the PGF
file in the SCRIPT_FILENAME variable, Apache passes it in PATH_TRANSLATED.
But perhaps this depends on exactly how the fastcgi service is configured.
The following is what I added to the Apache configuration file to test this:

	<Directory /Library/WebServer/Documents/fcgi-bin>
	  SetHandler fastcgi-script
	  Options +ExecCGI
	</Directory>
	Action pgf-service /fcgi-bin/pgf-service
	AddHandler pgf-service .pgf
2011-06-21 15:49:31 +00:00