Skip to content
Snippets Groups Projects
Unverified Commit 37ba0bca authored by Sebastian Höffner's avatar Sebastian Höffner
Browse files

Adding a small test set for the current state. Subject to change.

parent 0dae4e53
No related branches found
No related tags found
No related merge requests found
Showing
with 997 additions and 0 deletions
......@@ -4,3 +4,7 @@ app/generated_openccg_parser.py: OpenCCG.ebnf
.PHONY: run
run:
docker-compose run -p 5000:5000 -v $$(pwd)/app:/app openccg python3 /app/ccgapp.py
.PHONY: test
test:
docker-compose run -v $$(pwd)/app:/app -v $$(pwd)/tests:/tests openccg python3 -m unittest discover /tests
import json
import unittest
from pathlib import Path
# Shortcut to discover files inside the app instead of making it an installable
# package.
import os
os.sys.path.append(Path(__file__).parent / '..' / 'app')
import ccgparser
class CCGtoJSONTestCase(unittest.TestCase):
def setUp(self):
self.test_pairs_path = Path(os.path.dirname(__file__)) / 'test_pairs_ccg_json'
self.test_directories = list(self.test_pairs_path.glob('*'))
self.sentence_counter = 0
def test_ccg_to_json(self):
"""
Provides some example OpenCCG outputs and the expected JSON parses.
"""
for directory in self.test_directories:
with self.subTest(sentence=directory.name):
for ccg_file in directory.glob('*.ccg'):
test_case = ccg_file.name
with self.subTest(test_case=test_case):
ccg = ccg_file.read_text()
expected = json.loads(ccg_file.with_suffix('.json').read_text())
actual = ccgparser.ccg_to_json(ccg)
self.assertEqual(expected, actual)
@x1:gum-OrientationChange( <mood>imp ^ <gs-direction>(x2:gs-GeneralizedLocation ^ <gs-hasSpatialModality>(w2:slm-Cup ^ cup ^ <det>the ^ <ident>specific ^ <quant>singular)) ^ <gum-processInConfiguration>(w0:slm-Taking ^ slm-Taking))
{
"nominal": "x1:gum-OrientationChange",
"roles": [
{
"type": "mood",
"target": "imp"
},
[
{
"type": "gs-direction",
"target": {
"variable": "x2:gs-GeneralizedLocation",
"roles": {
"type": "gs-hasSpatialModality",
"target": {
"variable": "w2:slm-Cup",
"roles": [
{
"entity": "cup"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
}
}
},
{
"type": "gum-processInConfiguration",
"target": {
"variable": "w0:slm-Taking",
"roles": {
"entity": "slm-Taking"
}
}
}
]
]
}
@x1:gum-OrientationChange( <mood>imp ^ <gs-direction>(x2:gs-GeneralizedLocation ^ <gs-hasSpatialModality>(w2:slm-Cup ^ cup ^ <det>the ^ <ident>specific ^ <quant>singular)) ^ <gum-processInConfiguration>(w0:slm-Moving ^ slm-Taking))
{
"nominal": "x1:gum-OrientationChange",
"roles": [
{
"type": "mood",
"target": "imp"
},
[
{
"type": "gs-direction",
"target": {
"variable": "x2:gs-GeneralizedLocation",
"roles": {
"type": "gs-hasSpatialModality",
"target": {
"variable": "w2:slm-Cup",
"roles": [
{
"entity": "cup"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
}
}
},
{
"type": "gum-processInConfiguration",
"target": {
"variable": "w0:slm-Moving",
"roles": {
"entity": "slm-Taking"
}
}
}
]
]
}
@x1:gs-AffectingDirectedMotion( <mood>imperative ^ <gs-route>x2 ^ <gum-actee>(w2:slm-Cup ^ cup ^ <det>the ^ <ident>specific ^ <quant>singular) ^ <gum-processInConfiguration>(w0:slm-Taking ^ slm-Taking))
{
"nominal": "x1:gs-AffectingDirectedMotion",
"roles": [
{
"type": "mood",
"target": "imperative"
},
[
{
"type": "gs-route",
"target": "x2"
},
[
{
"type": "gum-actee",
"target": {
"variable": "w2:slm-Cup",
"roles": [
{
"entity": "cup"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
},
{
"type": "gum-processInConfiguration",
"target": {
"variable": "w0:slm-Taking",
"roles": {
"entity": "slm-Taking"
}
}
}
]
]
]
}
@x1:gs-AffectingDirectedMotion( <mood>imperative ^ <gs-route>x2 ^ <gum-actee>(w2:slm-Cup ^ cup ^ <det>the ^ <ident>specific ^ <quant>singular) ^ <gum-processInConfiguration>(w0:slm-Moving ^ slm-Taking))
{
"nominal": "x1:gs-AffectingDirectedMotion",
"roles": [
{
"type": "mood",
"target": "imperative"
},
[
{
"type": "gs-route",
"target": "x2"
},
[
{
"type": "gum-actee",
"target": {
"variable": "w2:slm-Cup",
"roles": [
{
"entity": "cup"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
},
{
"type": "gum-processInConfiguration",
"target": {
"variable": "w0:slm-Moving",
"roles": {
"entity": "slm-Taking"
}
}
}
]
]
]
}
Take the cup off the table and bring it to the shelf.
@x2:gum-MultiConfiguration( <alpha>(x3:gs-AffectingDirectedMotion ^ <mood>imperative ^ <gs-route>(x5:gs-GeneralizedRoute ^ <gs-pathPlacement>(x7:gs-GeneralizedLocation ^ <gs-hasSpatialModality>(w3:gs-DenialOfFunctionalControl ^ gs-DenialOfFunctionalControl) ^ <gs-relatum>(w5:slm-Table ^ slm-Table ^ <det>the ^ <ident>specific ^ <quant>singular))) ^ <gum-actee>(w2:slm-Cup ^ cup ^ <det>the ^ <ident>specific ^ <quant>singular) ^ <gum-processInConfiguration>(w0:slm-Taking ^ slm-Taking)) ^ <beta>(x4:gs-AffectingDirectedMotion ^ <mood>imperative ^ <gs-route>(x6:gs-GeneralizedRoute ^ <gs-destination>(x1:gs-GeneralizedLocation ^ <gs-hasSpatialModality>(w9:gs-GeneralDirectional ^ slm-To) ^ <gs-relatum>(w11:slm-Shelf ^ shelf ^ <det>the ^ <ident>specific ^ <quant>singular))) ^ <gum-actee>(w8:gum-ConsciousBeing ^ it ^ <number>singular ^ <person>third) ^ <gum-processInConfiguration>(w7:slm-Bringing ^ slm-Bringing)))
{
"nominal": "x2:gum-MultiConfiguration",
"roles": [
{
"type": "alpha",
"target": {
"variable": "x3:gs-AffectingDirectedMotion",
"roles": [
{
"type": "mood",
"target": "imperative"
},
{
"type": "gs-route",
"target": {
"variable": "x5:gs-GeneralizedRoute",
"roles": {
"type": "gs-pathPlacement",
"target": {
"variable": "x7:gs-GeneralizedLocation",
"roles": [
{
"type": "gs-hasSpatialModality",
"target": {
"variable": "w3:gs-DenialOfFunctionalControl",
"roles": {
"entity": "gs-DenialOfFunctionalControl"
}
}
},
{
"type": "gs-relatum",
"target": {
"variable": "w5:slm-Table",
"roles": [
{
"entity": "slm-Table"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
}
]
}
}
}
},
{
"type": "gum-actee",
"target": {
"variable": "w2:slm-Cup",
"roles": [
{
"entity": "cup"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
},
{
"type": "gum-processInConfiguration",
"target": {
"variable": "w0:slm-Taking",
"roles": {
"entity": "slm-Taking"
}
}
}
]
}
},
{
"type": "beta",
"target": {
"variable": "x4:gs-AffectingDirectedMotion",
"roles": [
{
"type": "mood",
"target": "imperative"
},
{
"type": "gs-route",
"target": {
"variable": "x6:gs-GeneralizedRoute",
"roles": {
"type": "gs-destination",
"target": {
"variable": "x1:gs-GeneralizedLocation",
"roles": [
{
"type": "gs-hasSpatialModality",
"target": {
"variable": "w9:gs-GeneralDirectional",
"roles": {
"entity": "slm-To"
}
}
},
{
"type": "gs-relatum",
"target": {
"variable": "w11:slm-Shelf",
"roles": [
{
"entity": "shelf"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
}
]
}
}
}
},
{
"type": "gum-actee",
"target": {
"variable": "w8:gum-ConsciousBeing",
"roles": [
{
"entity": "it"
},
{
"type": "number",
"target": "singular"
},
{
"type": "person",
"target": "third"
}
]
}
},
{
"type": "gum-processInConfiguration",
"target": {
"variable": "w7:slm-Bringing",
"roles": {
"entity": "slm-Bringing"
}
}
}
]
}
}
]
}
(@x2:gum-MultiConfiguration( <alpha>(x3:gs-AffectingDirectedMotion ^ <mood>imperative ^ <gs-route>(x5:gs-GeneralizedRoute ^ <gs-destination>(x1:gs-GeneralizedLocation ^ <gs-hasSpatialModality>(w9:gs-GeneralDirectional ^ slm-To) ^ <gs-relatum>(w11:slm-Shelf ^ shelf ^ <det>the ^ <ident>specific ^ <quant>singular))) ^ <gum-actee>w2:slm-Cup ^ <gum-processInConfiguration>(w0:slm-Moving ^ slm-Taking)) ^ <beta>(x4:gs-AffectingDirectedMotion ^ <mood>imperative ^ <gs-route>x5:gs-GeneralizedRoute ^ <gum-actee>(w8:gum-ConsciousBeing ^ it ^ <number>singular ^ <person>third) ^ <gum-processInConfiguration>(w7:slm-Bringing ^ slm-Bringing))) ^ @x7:gs-SpatialLocating( <gs-locatum>(w2:slm-Cup ^ cup ^ <det>the ^ <ident>specific ^ <quant>singular) ^ <gs-placement>(x6:gs-GeneralizedLocation ^ <gs-hasSpatialModality>(w3:gs-DenialOfFunctionalControl ^ slm-Off) ^ <gs-relatum>(w5:slm-Table ^ slm-Table ^ <det>the ^ <ident>specific ^ <quant>singular))))
[
{
"nominal": {
"nominal": "x2:gum-MultiConfiguration",
"roles": [
{
"type": "alpha",
"target": {
"variable": "x3:gs-AffectingDirectedMotion",
"roles": [
{
"type": "mood",
"target": "imperative"
},
{
"type": "gs-route",
"target": {
"variable": "x5:gs-GeneralizedRoute",
"roles": {
"type": "gs-destination",
"target": {
"variable": "x1:gs-GeneralizedLocation",
"roles": [
{
"type": "gs-hasSpatialModality",
"target": {
"variable": "w9:gs-GeneralDirectional",
"roles": {
"entity": "slm-To"
}
}
},
{
"type": "gs-relatum",
"target": {
"variable": "w11:slm-Shelf",
"roles": [
{
"entity": "shelf"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
}
]
}
}
}
},
{
"type": "gum-actee",
"target": "w2:slm-Cup"
},
{
"type": "gum-processInConfiguration",
"target": {
"variable": "w0:slm-Moving",
"roles": {
"entity": "slm-Taking"
}
}
}
]
}
},
{
"type": "beta",
"target": {
"variable": "x4:gs-AffectingDirectedMotion",
"roles": [
{
"type": "mood",
"target": "imperative"
},
{
"type": "gs-route",
"target": "x5:gs-GeneralizedRoute"
},
{
"type": "gum-actee",
"target": {
"variable": "w8:gum-ConsciousBeing",
"roles": [
{
"entity": "it"
},
{
"type": "number",
"target": "singular"
},
{
"type": "person",
"target": "third"
}
]
}
},
{
"type": "gum-processInConfiguration",
"target": {
"variable": "w7:slm-Bringing",
"roles": {
"entity": "slm-Bringing"
}
}
}
]
}
}
]
}
},
{
"nominal": {
"nominal": "x7:gs-SpatialLocating",
"roles": [
{
"type": "gs-locatum",
"target": {
"variable": "w2:slm-Cup",
"roles": [
{
"entity": "cup"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
},
{
"type": "gs-placement",
"target": {
"variable": "x6:gs-GeneralizedLocation",
"roles": [
{
"type": "gs-hasSpatialModality",
"target": {
"variable": "w3:gs-DenialOfFunctionalControl",
"roles": {
"entity": "slm-Off"
}
}
},
{
"type": "gs-relatum",
"target": {
"variable": "w5:slm-Table",
"roles": [
{
"entity": "slm-Table"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
}
]
}
}
]
}
}
]
(@x2:gum-MultiConfiguration( <alpha>(x3:gs-AffectingDirectedMotion ^ <mood>imperative ^ <gs-route>(x5:gs-GeneralizedRoute ^ <gs-destination>(x1:gs-GeneralizedLocation ^ <gs-hasSpatialModality>(w9:gs-GeneralDirectional ^ slm-To) ^ <gs-relatum>(w11:slm-Shelf ^ shelf ^ <det>the ^ <ident>specific ^ <quant>singular))) ^ <gum-actee>w2:slm-Cup ^ <gum-processInConfiguration>(w0:slm-Taking ^ slm-Taking)) ^ <beta>(x4:gs-AffectingDirectedMotion ^ <mood>imperative ^ <gs-route>x5:gs-GeneralizedRoute ^ <gum-actee>(w8:gum-ConsciousBeing ^ it ^ <number>singular ^ <person>third) ^ <gum-processInConfiguration>(w7:slm-Bringing ^ slm-Bringing))) ^ @x7:gs-SpatialLocating( <gs-locatum>(w2:slm-Cup ^ cup ^ <det>the ^ <ident>specific ^ <quant>singular) ^ <gs-placement>(x6:gs-GeneralizedLocation ^ <gs-hasSpatialModality>(w3:gs-DenialOfFunctionalControl ^ slm-Off) ^ <gs-relatum>(w5:slm-Table ^ slm-Table ^ <det>the ^ <ident>specific ^ <quant>singular))))
[
{
"nominal": {
"nominal": "x2:gum-MultiConfiguration",
"roles": [
{
"type": "alpha",
"target": {
"variable": "x3:gs-AffectingDirectedMotion",
"roles": [
{
"type": "mood",
"target": "imperative"
},
{
"type": "gs-route",
"target": {
"variable": "x5:gs-GeneralizedRoute",
"roles": {
"type": "gs-destination",
"target": {
"variable": "x1:gs-GeneralizedLocation",
"roles": [
{
"type": "gs-hasSpatialModality",
"target": {
"variable": "w9:gs-GeneralDirectional",
"roles": {
"entity": "slm-To"
}
}
},
{
"type": "gs-relatum",
"target": {
"variable": "w11:slm-Shelf",
"roles": [
{
"entity": "shelf"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
}
]
}
}
}
},
{
"type": "gum-actee",
"target": "w2:slm-Cup"
},
{
"type": "gum-processInConfiguration",
"target": {
"variable": "w0:slm-Taking",
"roles": {
"entity": "slm-Taking"
}
}
}
]
}
},
{
"type": "beta",
"target": {
"variable": "x4:gs-AffectingDirectedMotion",
"roles": [
{
"type": "mood",
"target": "imperative"
},
{
"type": "gs-route",
"target": "x5:gs-GeneralizedRoute"
},
{
"type": "gum-actee",
"target": {
"variable": "w8:gum-ConsciousBeing",
"roles": [
{
"entity": "it"
},
{
"type": "number",
"target": "singular"
},
{
"type": "person",
"target": "third"
}
]
}
},
{
"type": "gum-processInConfiguration",
"target": {
"variable": "w7:slm-Bringing",
"roles": {
"entity": "slm-Bringing"
}
}
}
]
}
}
]
}
},
{
"nominal": {
"nominal": "x7:gs-SpatialLocating",
"roles": [
{
"type": "gs-locatum",
"target": {
"variable": "w2:slm-Cup",
"roles": [
{
"entity": "cup"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
},
{
"type": "gs-placement",
"target": {
"variable": "x6:gs-GeneralizedLocation",
"roles": [
{
"type": "gs-hasSpatialModality",
"target": {
"variable": "w3:gs-DenialOfFunctionalControl",
"roles": {
"entity": "slm-Off"
}
}
},
{
"type": "gs-relatum",
"target": {
"variable": "w5:slm-Table",
"roles": [
{
"entity": "slm-Table"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
}
]
}
}
]
}
}
]
@x2:gum-MultiConfiguration( <alpha>(x3:gs-AffectingDirectedMotion ^ <mood>imperative ^ <gs-route>(x5:gs-GeneralizedRoute ^ <gs-pathPlacement>(x7:gs-GeneralizedLocation ^ <gs-hasSpatialModality>(w3:gs-DenialOfFunctionalControl ^ gs-DenialOfFunctionalControl) ^ <gs-relatum>(w5:slm-Table ^ slm-Table ^ <det>the ^ <ident>specific ^ <quant>singular))) ^ <gum-actee>(w2:slm-Cup ^ cup ^ <det>the ^ <ident>specific ^ <quant>singular) ^ <gum-processInConfiguration>(w0:slm-Moving ^ slm-Taking)) ^ <beta>(x4:gs-AffectingDirectedMotion ^ <mood>imperative ^ <gs-route>(x6:gs-GeneralizedRoute ^ <gs-destination>(x1:gs-GeneralizedLocation ^ <gs-hasSpatialModality>(w9:gs-GeneralDirectional ^ slm-To) ^ <gs-relatum>(w11:slm-Shelf ^ shelf ^ <det>the ^ <ident>specific ^ <quant>singular))) ^ <gum-actee>(w8:gum-ConsciousBeing ^ it ^ <number>singular ^ <person>third) ^ <gum-processInConfiguration>(w7:slm-Bringing ^ slm-Bringing)))
{
"nominal": "x2:gum-MultiConfiguration",
"roles": [
{
"type": "alpha",
"target": {
"variable": "x3:gs-AffectingDirectedMotion",
"roles": [
{
"type": "mood",
"target": "imperative"
},
{
"type": "gs-route",
"target": {
"variable": "x5:gs-GeneralizedRoute",
"roles": {
"type": "gs-pathPlacement",
"target": {
"variable": "x7:gs-GeneralizedLocation",
"roles": [
{
"type": "gs-hasSpatialModality",
"target": {
"variable": "w3:gs-DenialOfFunctionalControl",
"roles": {
"entity": "gs-DenialOfFunctionalControl"
}
}
},
{
"type": "gs-relatum",
"target": {
"variable": "w5:slm-Table",
"roles": [
{
"entity": "slm-Table"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
}
]
}
}
}
},
{
"type": "gum-actee",
"target": {
"variable": "w2:slm-Cup",
"roles": [
{
"entity": "cup"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
},
{
"type": "gum-processInConfiguration",
"target": {
"variable": "w0:slm-Moving",
"roles": {
"entity": "slm-Taking"
}
}
}
]
}
},
{
"type": "beta",
"target": {
"variable": "x4:gs-AffectingDirectedMotion",
"roles": [
{
"type": "mood",
"target": "imperative"
},
{
"type": "gs-route",
"target": {
"variable": "x6:gs-GeneralizedRoute",
"roles": {
"type": "gs-destination",
"target": {
"variable": "x1:gs-GeneralizedLocation",
"roles": [
{
"type": "gs-hasSpatialModality",
"target": {
"variable": "w9:gs-GeneralDirectional",
"roles": {
"entity": "slm-To"
}
}
},
{
"type": "gs-relatum",
"target": {
"variable": "w11:slm-Shelf",
"roles": [
{
"entity": "shelf"
},
{
"type": "det",
"target": "the"
},
{
"type": "ident",
"target": "specific"
},
{
"type": "quant",
"target": "singular"
}
]
}
}
]
}
}
}
},
{
"type": "gum-actee",
"target": {
"variable": "w8:gum-ConsciousBeing",
"roles": [
{
"entity": "it"
},
{
"type": "number",
"target": "singular"
},
{
"type": "person",
"target": "third"
}
]
}
},
{
"type": "gum-processInConfiguration",
"target": {
"variable": "w7:slm-Bringing",
"roles": {
"entity": "slm-Bringing"
}
}
}
]
}
}
]
}
(@x2:gum-MultiConfiguration( <alpha>(x3:gs-AffectingDirectedMotion ^ <mood>imperative ^ <gs-route>x5 ^ <gum-actee>w2:slm-Cup ^ <gum-processInConfiguration>(w0:slm-Taking ^ slm-Taking)) ^ <beta>(x4:gs-AffectingDirectedMotion ^ <mood>imperative ^ <gs-route>(x6:gs-GeneralizedRoute ^ <gs-destination>(x1:gs-GeneralizedLocation ^ <gs-hasSpatialModality>(w9:gs-GeneralDirectional ^ slm-To) ^ <gs-relatum>(w11:slm-Shelf ^ shelf ^ <det>the ^ <ident>specific ^ <quant>singular))) ^ <gum-actee>(w8:gum-ConsciousBeing ^ it ^ <number>singular ^ <person>third) ^ <gum-processInConfiguration>(w7:slm-Bringing ^ slm-Bringing))) ^ @x8:gs-SpatialLocating( <gs-locatum>(w2:slm-Cup ^ cup ^ <det>the ^ <ident>specific ^ <quant>singular) ^ <gs-placement>(x7:gs-GeneralizedLocation ^ <gs-hasSpatialModality>(w3:gs-DenialOfFunctionalControl ^ slm-Off) ^ <gs-relatum>(w5:slm-Table ^ slm-Table ^ <det>the ^ <ident>specific ^ <quant>singular))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment