This module provides classes and functions that implement a subset of the DELPH-IN Web API DELPH-IN Web API described here:


Requires Falcon ( This dependency is satisfied if you install PyDelphin with the [web] extra (see Requirements, Installation, and Testing).

In addition to the parsing API, this module also provides support for generation and for browsing [incr tsdb()] test suites. In order to use it, you will need a WSGI server such as gunicorn, mod_wsgi for Apache2, etc. You then write a WSGI stub for the server to use, such as the following example:

# file:

import falcon

from delphin.web import server

application = falcon.API()

        'gold': [
            {'name': 'mrs', 'path': '~/grammars/erg/tsdb/gold/mrs'}

You can then run a local instance using, for instance, gunicorn:

$ gunicorn wsgi
[2019-07-12 16:03:28 +0800] [29920] [INFO] Starting gunicorn 19.9.0
[2019-07-12 16:03:28 +0800] [29920] [INFO] Listening at: (29920)
[2019-07-12 16:03:28 +0800] [29920] [INFO] Using worker: sync
[2019-07-12 16:03:28 +0800] [29923] [INFO] Booting worker with pid: 29923

And make requests with, for instance, curl:

$ curl '' -v
*   Trying
* Connected to ( port 8000 (#0)
> GET /parse?input=Abrams%20slept.&mrs HTTP/1.1
> Host:
> User-Agent: curl/7.61.0
> Accept: */*
< HTTP/1.1 200 OK
< Server: gunicorn/19.9.0
< Date: Fri, 12 Jul 2019 08:04:29 GMT
< Connection: close
< content-type: application/json
< content-length: 954
* Closing connection 0
{"input": "Abrams slept.", "readings": 1, "results": [{"result-id": 0, "mrs": {"top": "h0", "index": "e2", "relations": [{"label": "h4", "predicate": "proper_q", "arguments": {"ARG0": "x3", "RSTR": "h5", "BODY": "h6"}, "lnk": {"from": 0, "to": 6}}, {"label": "h7", "predicate": "named", "arguments": {"CARG": "Abrams", "ARG0": "x3"}, "lnk": {"from": 0, "to": 6}}, {"label": "h1", "predicate": "_sleep_v_1", "arguments": {"ARG0": "e2", "ARG1": "x3"}, "lnk": {"from": 7, "to": 13}}], "constraints": [{"relation": "qeq", "high": "h0", "low": "h1"}, {"relation": "qeq", "high": "h5", "low": "h7"}], "variables": {"e2": {"type": "e", "properties": {"SF": "prop", "TENSE": "past", "MOOD": "indicative", "PROG": "-", "PERF": "-"}}, "x3": {"type": "x", "properties": {"PERS": "3", "NUM": "sg", "IND": "+"}}, "h5": {"type": "h"}, "h6": {"type": "h"}, "h0": {"type": "h"}, "h1": {"type": "h"}, "h7": {"type": "h"}, "h4": {"type": "h"}}}}], "tcpu": 7, "pedges": 17}

Module Functions

delphin.web.server.configure(api, parser=None, generator=None, testsuites=None)[source]

Configure server application api.

This is the preferred way to setup the server application, but the task-specific classes defined in this module can also be used to setup custom routes, for instance.

If a path is given for parser or generator, it will be used to construct a ParseServer or GenerationServer instance, respectively, with default arguments to the underlying ACEProcessor. If non-default arguments are needed, pass in the customized ParseServer or GenerationServer instances directly.

  • api – an instance of falcon.API

  • parser – a path to a grammar or a ParseServer instance

  • generator – a path to a grammar or a GenerationServer instance

  • testsuites – mapping of collection names to lists of test suite entries


>>> server.configure(
...     api,
...     parser='~/grammars/erg-2018-x86-64-0.9.30.dat',
...     testsuites={
...         'gold': [
...             {'name': 'mrs',
...              'path': '~/grammars/erg/tsdb/gold/mrs'}]})

Server Application Classes

class delphin.web.server.ProcessorServer(grammar, *args, **kwargs)[source]

A server for results from an ACE processor.


This class is not meant to be used directly. Use a subclass instead.

class delphin.web.server.ParseServer(grammar, *args, **kwargs)[source]

Bases: delphin.web.server.ProcessorServer

A server for parse results from ACE.


alias of delphin.ace.ACEParser

class delphin.web.server.GenerationServer(grammar, *args, **kwargs)[source]

Bases: delphin.web.server.ProcessorServer

A server for generation results from ACE.


alias of delphin.ace.ACEGenerator

class delphin.web.server.TestSuiteServer(testsuites, transforms=None)[source]

A server for a collection of test suites.

  • testsuites – list of test suite descriptions

  • transforms – mapping of table names to lists of (column, transform) pairs.