Open alexandru-dinu opened 1 year ago
Potential idea: bias random.choice
towards selecting terminals the deeper we are in the tree.
For e.g., for a rule like <s> ::= "foo" | <s> <s>
and starting from a uniform distribution, we can increase the proba of selecting the first or-group ("foo"
) w.r.t. the depth.
Added an initial fix: return None
when reaching max depth and don't propagate None
results upwards.
However, the caveat is that we have to loop until we find a good match:
https://github.com/alexandru-dinu/synx/blob/37ddb570e797068450277300f9fefd0cfb8603ba/synx/synx.py#L228-L230
Currently, for recursive grammars like:
weird strings are produced due to how
max_depth
is handled: