A minimalist generative grammar library
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.circleci
bin
lib
spec
.gitignore
.rspec
.rubocop.yml
Gemfile
LICENSE.txt
README.md
Rakefile
wordz.gemspec

README.md

Gem Version Build Maintainability

Wordz

A minimalist generative grammar library. For use in bots and other mischief.

Usage

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."