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

Integrating the ccgparser method into the wccg module.

parent b55f97fd
No related branches found
No related tags found
No related merge requests found
from tatsu.util import asjson
from tatsu.model import ModelBuilderSemantics
from generated_openccg_parser import OpenCCGParser
def ccg_to_json(to_parse):
"""Parses an OpenCCG string into a more easily digestiable JSON format.
Args:
to_parse: The OpenCCG string.
Returns:
A JSON representation of the OpenCCG string.
"""
return asjson(OpenCCGParser().parse(to_parse,
semantics=ModelBuilderSemantics(),
parseinfo=False))
......@@ -3,7 +3,10 @@ import re
import string
import subprocess
from ccgparser import ccg_to_json
from tatsu.util import asjson
from tatsu.model import ModelBuilderSemantics
from generated_openccg_parser import OpenCCGParser
def parse(sentence):
......@@ -117,3 +120,16 @@ def jsonify_parses(wccg_response):
copy = wccg_response.copy()
copy['json_parses'] = json_parses
return copy
def ccg_to_json(to_parse):
"""Parses an OpenCCG string into a more easily digestiable JSON format.
Args:
to_parse: The OpenCCG string.
Returns:
A JSON representation of the OpenCCG string.
"""
return asjson(OpenCCGParser().parse(to_parse,
semantics=ModelBuilderSemantics(),
parseinfo=False))
......@@ -9,7 +9,7 @@ import os
os.sys.path.append(Path(__file__).parent / '..' / 'app')
import ccgparser # noqa
import wccg # noqa
class CCGtoJSONTestCase(unittest.TestCase):
......@@ -28,4 +28,4 @@ class CCGtoJSONTestCase(unittest.TestCase):
ccg = test_case['ccg']
expected = test_case['json']
self.assertEqual(expected, ccgparser.ccg_to_json(ccg))
self.assertEqual(expected, wccg.ccg_to_json(ccg))
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