MCPcopy Create free account
hub / github.com/Notgnoshi/generative / generate_rule

Function generate_rule

tools/random-production-rules.py:256–270  ·  view source on GitHub ↗

Generate a rule for the given token.

(token, distribution, base_biases, temperature, rng, dynamic)

Source from the content-addressed store, hash-verified

254
255
256def generate_rule(token, distribution, base_biases, temperature, rng, dynamic):
257 """Generate a rule for the given token."""
258 biases = base_biases.copy()
259 length = rng.integers(3, 20)
260 production = ""
261 for _ in range(length):
262 alpha = 1.5
263 biases[token] *= alpha
264 new_token = generate_rhs_token(distribution, biases, rng, temperature, dynamic, alpha)
265 if new_token == token:
266 biases[token] = 1
267 production += new_token
268 # TODO: Close any unmatched pops, pushes or drawing toggles.
269 # Prepend ['s and d's. Append ]'s and D's. Only add up to one 'd' or 'D'.
270 return production
271
272
273def pairwise(iterable):

Callers 1

mainFunction · 0.85

Calls 1

generate_rhs_tokenFunction · 0.85

Tested by

no test coverage detected