Tools for JSGF grammar expansion.
Project description
JSGF Grammar Tools for Leyzer corpus
Introduction
This library generate strings from a JSGF grammar. Although it can be used to generate strings from any JSGF grammar it was created as auxilary tool for Leyzer (https://github.com/cartesinus/leyzer) grammars generation. It is slightly modified version of https://github.com/syntactic/JSGFTools.
Notes:
- Larger grammars take a longer time to parse, so if nothing seems to be generating, wait a few seconds and the grammar should be parsed.
- Most of JSGF as described in http://www.w3.org/TR/2000/NOTE-jsgf-20000605/ is
supported, but there are a few things that have not been implemented by these
tools yet:
- Kleene operators
- Imports and Grammar Names
- Tags
Dependencies:
- Python 3.7
- PyParsing 3.0.9
JSGFTools were originaly created by Pastèque Ho (and others).
Library Usage
To generate strings from grammar use it as in below example. Below example use grammar that is included in this repository. Other, more complex grammars, can be found in https://github.com/cartesinus/leyzer repository.
from from JSGFToolsLeyzer import parser
fs = open("Ideas.gram")
grammar = parser.getGrammarObject(fs)
for rule in grammar.publicRules:
expansions = processRHS(rule.rhs, grammar)
for expansion in expansions:
print(expansion)
License
MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for JSGFToolsLeyzer-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9c1f493a78f7e825578ee6dad77ae8bc40338cf278d1030a9c535ace892d4b2 |
|
MD5 | 81e92b40ac35f87859bb955227b7fba6 |
|
BLAKE2b-256 | 793398c9721fd592179b15dd04fd1254000535ced3c4c512963aaf9eefff4697 |