There are three different types of objects: Nominal, Variable, and Role. The full
semantic specification (the JSON file) can either be one single entity of any of the
three types or a list of Nominals. If we find parses which are lists of
variables or roles, the grammar will be extended. Please open an issue if you
find sentences which can not be parsed correctly.
#### Nominal and Variable
A nominal is like a special variable, it describes the "main theme" of the sentence.
Since they are practically the same (they actually have very similar parsing
rules), the JSON format represents them with an identical structure:
```json
{
"__class__":"Variable",
"name":"x1",
"type":"gum-OrientationChange",
"roles":[]
}
```
-`__class__` is either `Variable` or `Nominal`.
-`name` is the variable named used by OpenCCG, it is a letter followed by a number, for example `x1` or `w12`.
-`type` is a [GUM](https://www.ontospace.uni-bremen.de/ontology/stable/GUM-3-space.owl) specifier denoting the type of the variable. It can also be `null`, if the type is not specified.
-`roles` is a list of roles as described below.
#### Role
A Role defines all properties a Variable or Nominal can have.
It follows a very similar structure:
```json
{
"__class__":"Role",
"type":"quant",
"target":...
}
```
-`__class__`: `Role`.
-`type`: The role type. This determines the `target` possibilities.
-`target`: The value of the role. This can be multiple different things, see below.
If the type is `entity`, the target will be an instance, like "cup" or "slm-Taking".
If the type has a prefix followed by a dash, e.g. `gs-hasSpatialModality` or `gs-direction`, then the target will be a `Variable`.
If the type is any other string, the target will be an atomic string, e.g. the type `det` can have the target `the`, while the type `quant` can have the target `singular`.
### Changing the port
Most web services use port 80 as a default port, and so does web-openccg.
To change the port, adjust the docker-compose file and change the port line
from `"80:80"` to your port on the left side (but keep the 80 on the right), so
for example to set up the service on Port 9043, you would change it to
`"9043:80"`.
## Development
Although not necessarily needed, I use a pipenv for local development to be
able to compile the grammar to a parser using TatSu.
I rely on [when-changed](https://github.com/joh/when-changed) to trigger
automatic builds:
when-changed OpenCCG.ebnf make
To start the development docker container, use the Makefile:
make run
The development server binds to port 5000 and uses the
[flask](http://flask.pocoo.org/) debug environment. Additionally, the docker
container started with `make run` binds the app directory
so that flask's reloading works properly.
## Example response
An example response for the sentence "Take the cup." is:
```json
...
...
@@ -356,90 +455,3 @@ An example response for the sentence "Take the cup." is:
}
}
```
### JSON format
Current version: 2.1.0
The JSON format for the OpenCCG parses can be determined from the example above
There are three different types of objects: Nominal, Variable, and Role. The full
semantic specification (the JSON file) can either be one single entity of any of the
three types or a list of Nominals. If we find parses which are lists of
variables or roles, the grammar will be extended. Please open an issue if you
find sentences which can not be parsed correctly.
#### Nominal and Variable
A nominal is like a special variable, it describes the "main theme" of the sentence.
Since they are practically the same (they actually have very similar parsing
rules), the JSON format represents them with an identical structure:
```json
{
"__class__":"Variable",
"name":"x1",
"type":"gum-OrientationChange",
"roles":[]
}
```
-`__class__` is either `Variable` or `Nominal`.
-`name` is the variable named used by OpenCCG, it is a letter followed by a number, for example `x1` or `w12`.
-`type` is a [GUM](https://www.ontospace.uni-bremen.de/ontology/stable/GUM-3-space.owl) specifier denoting the type of the variable. It can also be `null`, if the type is not specified.
-`roles` is a list of roles as described below.
#### Role
A Role defines all properties a Variable or Nominal can have.
It follows a very similar structure:
```json
{
"__class__":"Role",
"type":"quant",
"target":...
}
```
-`__class__`: `Role`.
-`type`: The role type. This determines the `target` possibilities.
-`target`: The value of the role. This can be multiple different things, see below.
If the type is `entity`, the target will be an instance, like "cup" or "slm-Taking".
If the type has a prefix followed by a dash, e.g. `gs-hasSpatialModality` or `gs-direction`, then the target will be a `Variable`.
If the type is any other string, the target will be an atomic string, e.g. the type `det` can have the target `the`, while the type `quant` can have the target `singular`.
### Changing the port
Most webservices use port 80 as a default port, and so does web-openccg.
To change the port, adjust the docker-compose file and change the port line
from `"80:80"` to your port on the left side (but keep the 80 on the right), so
for example to set up the service on Port 9043, you would change it to
`"9043:80"`.
## Development
Although not necessarily needed, I use a pipenv for local development to be
able to compile the grammar to a parser using TatSu.
I rely on [when-changed](https://github.com/joh/when-changed) to trigger
automatic builds:
when-changed OpenCCG.ebnf make
To start the development docker container, use the Makefile:
make run
The development server binds to port 5000 and uses the
[flask](http://flask.pocoo.org/) debug environment. Additionally, the docker
container started with `make run` binds the app directory