Initialize a Lindenmayer-System grammar parser with the given rules. :param rules: A set of production rules. A mapping of token -> replacements.
(
self,
rules: MultiDict[TokenName, RuleMapping],
ignore: Set[TokenName] = None,
seed: int = None,
)
| 76 | """ |
| 77 | |
| 78 | def __init__( |
| 79 | self, |
| 80 | rules: MultiDict[TokenName, RuleMapping], |
| 81 | ignore: Set[TokenName] = None, |
| 82 | seed: int = None, |
| 83 | ): |
| 84 | """Initialize a Lindenmayer-System grammar parser with the given rules. |
| 85 | |
| 86 | :param rules: A set of production rules. A mapping of token -> replacements. |
| 87 | """ |
| 88 | self.ignore: Set[TokenName] = ignore if ignore is not None else set() |
| 89 | self.rules: MultiDict[TokenName, RuleMapping] = rules |
| 90 | |
| 91 | self.seed = seed if seed is not None else random.randint(0, 2**32 - 1) |
| 92 | np.random.seed(self.seed) |
| 93 | logger.info(f"Using random seed: {self.seed}") |
| 94 | |
| 95 | def pick_rule(self, rules: List[RuleMapping], token, left_ctx, right_ctx) -> RuleMapping: |
| 96 | """Pick the right rule based off the probability values or the parametric condition.""" |
nothing calls this directly
no outgoing calls
no test coverage detected