-
Notifications
You must be signed in to change notification settings - Fork 2
Getting start
CNLWizard is a tool developed to facilitate the specification of Controlled Natural Language and its translation into a target knowledge representation formalism.
It operates through two main computational steps. The former corresponds to the generation of a formal grammar and the imperative functions specifying how each grammar element should be compiled, while the latter makes use of the components generated in the first step for the actual translation of a CNL file into a target language representation.
For the first step, CNLWizard expects a YAML file (see https://yaml.org/ for the syntax of YAML) specifying a set of commands. After processing the YAML file, CNLWizard generates a grammar and a Python file containing the corresponding imperative functions.
In the second step, CNLWizard applies the generated grammar to parse a CNL file, automatically producing an AST, and then it obtains the translated CNL by evaluating each node of the tree with the corresponding functions generated in the previous step.
Dependencies:
- lark:
pip install lark - yaml:
pip install PyYAML
CP also requires:
- ortools (for CP):
pip install ortools
SMT also requires:
- z3 (for SMT):
pip install z3-solver
SAT also requires:
- python-sat:
pip install python-sat - sympy:
pip install sympy
Generate grammar and Python functions
python3 src/main.py -g YAML
where YAML is the file containing the CNL specification in YAML format.
Compile the CNL
python3 src/main.py -c GRAMMAR PY_FUNCTIONS CNL
where GRAMMAR is the generated grammar in Lark format, PY_FUNCTIONS is the file containing the implemented Python functions, and CNL is the CNL text that will be translated.