This file deterministically generates strings from a JSGF Grammar, whether there are weights defined in rules or not. It requires one argument: the path to the JSGF Grammar file. You can run this on the included grammar IdeasNonRecursive.gram:
python DeterministicGenerator.py IdeasNonRecursive.gram
This will generate all strings defined by the public rules of IdeasNonRecursive.gram. It is important that the grammar used by the generator is not recursive (rules should not directly or indirectly reference themselves), so that the generator terminates. Otherwise, you may get a maximum recursion depth exceeded error or a segmentation fault.
Combines sets of strings by taking the cross product of the sets and concatenating the elements in the resulting tuples
Parameters: | listOfSets – 2-D list of strings |
---|---|
Returns: | a list of strings |
Returns the string representations of a set of alternatives
Returns: | list of strings, where each string is each alternative |
---|
Finds the rule expansion for a nonterminal and returns its expansion.
Returns the string representations of an optional grouping
Returns: | list of strings, including an empty string |
---|
Depending on the type of the argument, calls the corresponding function to deal with that type.
Parameters: | rhs (either a JSGF Expression, list, or string) – portion of JSGF rule |
---|---|
Returns: | list of strings |
Combines adjacent elements in a sequence