Commit Graph

322 Commits

Author SHA1 Message Date
aarne
ee2f3d085e vd command now reads local concrete configurations to deal with syncat words; TODO: dissolve clustered multiwords bound with + 2017-04-06 11:55:21 +00:00
hallgren
ae512e09e0 Fix compilation errors caused by changes in PGF2
These prevented GF from being built with C run-time support (-fc-runtime).
2017-02-21 13:21:59 +00:00
hallgren
83d340dbef PGFService: fix a type ambiguity when compiling without C run-time support
The function listCaches returns an empty list instead of the contents
of the cached C run-time system PGFs when compiled without C-run-time support
This gave rise to an ambiguity in GF.Server.
2016-06-17 11:32:40 +00:00
hallgren
096b4cfcee PGF service & minibar: only show dependency diagrams if the labels are known
+ The PGF service now reads and caches dependency label configuration files.
+ The grammar info returned by command=grammar has a new boolean field 
  'hasDependencyLabels' to indicate if dependency labels were found for
  the grammar. Also, command=deptree will now fail if no labels are present.
+ The minibar only shows word dependency trees if labels are present.
+ Also changed the type of getDepLabels from [String] -> Labels to
  String -> Labels, since all uses were in the form "getDepLabels . lines".
2016-06-09 13:12:14 +00:00
hallgren
617624e2a8 PGFService: eleminate warning "Defined but not used: ‘serverError’" 2016-06-09 11:27:57 +00:00
hallgren
a59821eb80 PGF web service: switch to the new SVG rendering of word dependency trees
Also added the function outputText in CGIUtils.
2016-06-08 19:10:23 +00:00
hallgren
9f1da17d06 PGFService.hs: fix compilation problem when C run-time support is omitted 2016-05-26 13:56:43 +00:00
hallgren
cfdd9621ff PGF web service: add command=deptree
This is the web interface to PGF.graphvizDependencyTree.

Accepted parameters: format=<output_format>, to=<lang>, tree=<tree>.

Accepted output formats: latex, conll, malt_tab, malt_input, png, gif, svg, gv

Also, label information is taken from <path>.labels if present, where
<path>.pgf is the path to the PGF file.
2016-05-26 13:39:48 +00:00
krasimir
86c5423275 the Literals API in Haskell no longer offers the sentence as an argument to the callbacks. It is just as easy to save the sentence in a closure and by doing that we save the repeated round about from C to Haskell strings 2016-05-11 11:10:22 +00:00
aarne
e39787ab88 prepared visualize_parse for showing dependency labels 2015-11-04 17:28:09 +00:00
hallgren
5bfaf10de5 Comment out some dead code found with -fwarn-unused-binds
Also fixed some warnings and tightened some imports
2015-08-28 13:59:43 +00:00
hallgren
e9c060d3f9 PGF web service: option to leave &+ uninterpreted in linearized output
By adding unlexer=none (or unlexer=id) in requests that output linearizations
(e.g. command=linearize, command=translate), you can leave &+ uninterpreted
instead of gluing the adjacent tokens. This means that the output is left in
a format that can be parsed in a subsequent request.

To implement this consistently, the function linearizeAndBind was replaced
with the function linearizedAndUnlex (but there are a couple of requests
that do not call this function...)

Note that this applies to the Haskell run-time requests only. The C run-time
request (c-linearize, c-translate) always applies the &+ token and the
c-parse request can parse input containing glued tokens.
2015-07-21 14:21:49 +00:00
hallgren
3263968c79 gf -server: include grammar modification time in the info returned by /version 2015-04-17 13:21:20 +00:00
hallgren
9e3afea129 PGF web service: add command c-linearizeAll to obtain all variants
Implemented by calling the recently added function PGF2.linearizeAll.
2015-04-17 12:59:03 +00:00
hallgren
6d72126ffc PGF Service: add an option to return syntax trees in JSON format
The parse/translate/c-parse/c-translate commands now recognize the option
jsontree=true to augment the returned JSON structure with a field called
"jsontree" next to the field "tree", or "jsontrees" next to "trees",
containing the the returned syntax tree in JSON format (the same format
returned by the abstrjson command, similar to the format returned in the
"brackets" field).
2015-03-24 17:37:43 +00:00
hallgren
5db57b1a58 PGF service: add commands c-abstrtree and c-parsetree
These are the C runtime variants of the absttree and parsetree commands. They
work in the same way, but support fewer rendering options.
2015-03-19 14:17:45 +00:00
hallgren
9c6b5df741 PGFService: make the restriction on parallelism more effective
Restrict the entire request handler instead of just the call to the C parser.
2015-02-25 16:08:21 +00:00
hallgren
e68370e463 PGFService.hs: text lexer: slightly smarter decapitalization of the first word of a sentence
Keep the first letter in upper case if it is followed by more upper case
letters.

(Also remove some left over debugging output.)
2015-02-24 15:04:06 +00:00
hallgren
f6cb6d172e PGF Service: limit the number of parallel calls to the C run-time parse function to 4 by default
The limit can be changed with the -j flag
2015-02-20 12:29:44 +00:00
hallgren
54ae70a81e Changes for compatibility with ghc-7.10-rc2
2 modules: Name clashes caused by Applicative-Monad change in Prelude
2 modules: Ambiguities caused by Foldable/Traversable in Prelude
2 modules: Backwards incompatible changes in time-1.5 for defaultTimeLocale
9 modules: {-# LANGUAGE FlexibleContexts #-} (because GHC checks inferred types
           now, in addition to explicitly given type signatures)

Also silenced warnings about tab characters in source files.
2015-02-16 15:05:06 +00:00
hallgren
ffe1f74584 PGF2 & PGFService: enable callbacks for named entities and chunks in the c-parse & c-translate web requests 2015-01-21 10:41:12 +00:00
hallgren
3f3df9a719 PGF2 & PGFService: work in progress on callbacks for nerc & chunks 2015-01-20 14:57:52 +00:00
hallgren
a21ffc1941 gf.cabal, gf-server.cabal: add version bounds on network & httpd-shed
* httpd-shed-0.4 does not specify an upper bound on network, but it fails
  to build against network>=2.6. This is fixed in httpd-shed-0.4.0.2.
* With network-2.6, the Network.URI modules is moved to a separate package,
  so for the time being GF requires network>=2.3 && <2.6. This is compatible
  with the four most recent versions of the Haskell Platform.
2014-09-03 15:40:26 +00:00
hallgren
e0e6079c91 src/server: refactoring to isolate dependencies on the cgi/fastcgi packages
* Introducing the module CGI, re-exporting a subset of the cgi package. It
  might complete replace the cgi package in the future.
* Introducing the module CGIUtils, containing functions from FastCGIUtils that
  have nothing to do with fastcgi.

Some low level hackery with unsafePerformIO and global variables was left
in FastCGIUtils, but it is actually not used, neither for gf -server nor
exec/pgf-fcgi.hs.
2014-09-02 12:27:47 +00:00
hallgren
3660339b23 PGF service: expire PGFs from the cache when they have been unused for 24 hours
...to keep memory use down on the server.
2014-07-21 15:53:38 +00:00
hallgren
3ec95e481b src/server/gf-server.cabal: update dependencies 2014-07-15 12:00:51 +00:00
john.j.camilleri
37a35734a5 PGF Web Service: include entire completion in full mode
When using full=yes in the web service 'complete' command,
you now get an additional field 'seq' with the longest possible completion.
So, given:

  lin
    f1 = ss "the" ;
    f2 = ss ("the red house" | "the real deal") ;

and trying to complete on input "th", you get:

    [
        {
            "from": "TestCnc",
            "brackets": {
                "cat": "_",
                "fid": 0,
                "index": 0,
                "fun": "_",
                "children": []
            },
            "text": "th",
            "completions": [
                {
                    "token": "the",
                    "funs": [
                        {
                            "fun": "f1",
                            "hyps": [],
                            "cat": "C",
                            "seq": "the"
                        },
                        {
                            "fun": "f2",
                            "hyps": [],
                            "cat": "C",
                            "seq": "the red house"
                        },
                        {
                            "fun": "f2",
                            "hyps": [],
                            "cat": "C",
                            "seq": "the real deal"
                        }
                    ]
                }
            ]
        }
    ]
2014-07-15 09:33:22 +00:00
john
9b49608451 PGF web service: Return additional completion info with 'full' flag
BETA! The 'complete' command now has a new flag 'full' which when set
returns additional info about completions.

Without 'full' flag (default):

[
    {
        "from": "PhrasebookEng",
        "brackets": {
            "cat": "_",
            "fid": 0,
            "index": 0,
            "fun": "_",
            "children": [
                {
                    "token": "the"
                }
            ]
        },
        "text": "su",
        "completions": [
            "supermarket",
            "suspect"
        ]
    }
]

With full=true or full=yes:

[
    {
        "from": "PhrasebookEng",
        "brackets": {
            "cat": "_",
            "fid": 0,
            "index": 0,
            "fun": "_",
            "children": [
                {
                    "token": "the"
                }
            ]
        },
        "text": "su",
        "completions": [
            {
                "token": "supermarket",
                "funs": [
                    {
                        "fid": 421,
                        "fun": "Supermarket",
                        "hyps": [],
                        "cat": "PlaceKind"
                    }
                ]
            },
            {
                "token": "suspect",
                "funs": [
                    {
                        "fid": 445,
                        "fun": "Suspect",
                        "hyps": [],
                        "cat": "Property"
                    }
                ]
            }
        ]
    }
]
2014-07-11 09:25:26 +00:00
hallgren
9eb6557376 PGF Service: return error code 404 (not found) instead of 500 (internal server error) for missing grammars 2014-06-20 17:28:02 +00:00
hallgren
ef20e8cbac PGF Service, command=grammar: include the last modified time of the grammar in the output 2014-06-20 10:34:51 +00:00
hallgren
7c9ff164bf gf -server: include list of loaded PGFs in version info 2014-05-12 13:45:36 +00:00
hallgren
8d9816ee98 PGF web api, command c-wordforword: re-enable parsing of individual words
The space leak in the Haskell binding to the C parser has been fixed.
2014-05-08 11:38:41 +00:00
hallgren
a7b1f9e1b3 PGF web api, command c-wordforword: don't repeat parsing/morpho analysis for each target language
Also omit attemts to parse individual words for now, to avoid space leaks in
the Haskell binding to the C parser.
2014-04-29 15:51:46 +00:00
hallgren
2721f7358f Spring cleaning
Nothing major...
2014-04-28 13:56:20 +00:00
hallgren
dd96c8a2c6 PGF web API: adding the command c-wordforword
It has the same parameters and result format as c-translate, but it does
the translation word for word. (To be used as a last resort).
2014-04-16 15:24:23 +00:00
hallgren
7fc3627c6e PGF web API: add commands lookupmorpho and c-lookupmorpho 2014-04-15 14:50:38 +00:00
hallgren
4008a2b111 PGF web service: disable caching of parse results
Caching parse results uses a lot of memory, even if they expire after
2 minutes, so it won't scale up to many simultaneous users.

But some excessive memory use seems to be caused by space leaks in
(the Haskell binding to) the C run-time system, and these should be fixed.
For example, flushing the PGF cache does not release the memory allocated
by the C run-time system when loading a PGF file.
2014-04-10 15:55:33 +00:00
hallgren
d1da0e06de PGF web service: add unlexers and enable client side caching
Most PGF web API commands that produce linearizations now accept an
unlexer parameter. Possible values are "text", "code" and "mixed".

The web service now include Date and Last-Modified headers in the HTTP,
responses. This means that browsers can treat responses as static content and
cache them, so it becomes less critical to cache parse results in the server.

Also did some cleanup in PGFService.hs, e.g. removed a couple of functions
that can now be imported from PGF.Lexing instead.
2014-04-09 17:51:25 +00:00
hallgren
04a6260eea PGF Service: a bit more clever lexer=text
Only change the first word to lowercase if the original input is not found in
the grammar's morphology. This allows parsing of sentenses starting with "I" in 
English, nouns in German and proper names in other languages, but it can make
the wrong choice for multi-words.
2014-04-09 14:13:18 +00:00
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