A minimalist generative grammar library. For use in bots and other mischief.
grammar = {
"<root>" => [
["#dog#name#", "says", "<bark>", "."],
],
"<bark>" => [
["ruff"],
["woof"],
]
}
class Dog
def name
"Daisy"
end
end
Wordz.generate(
grammar: grammar,
subjects: { dog: Dog.new },
)
# Will return one of the following, at random.
# => "Daisy says ruff."
# => "Daisy says arf."