Project

chain_punk

0.0
No release in over 3 years
Low commit activity in last 3 years
Generate text from configurable patterns.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.17
~> 10.0
~> 3.0
~> 0.65
 Project Readme

Chain Punk ⛓👽

Chain Punk generates text from markov chains defined by configurable patterns.

Installation

Add this line to your application's Gemfile:

gem 'chain_punk'

And then execute:

$ bundle

Or install it yourself as:

$ gem install chain_punk

Usage

Generate five names from a sample set of English names:

require 'chain_punk'

text = IO.read('docs/names.txt').downcase
corpus = ChainPunk::Corpus.new(text, closures: ["\n"], exclusions: [' '])
generator = ChainPunk::Generator.new(corpus.frequency_table)
[*1..5].each { puts generator.generate(rand(4..8)).capitalize }

Outputs:

Iniandi
Frbbemar
Gitelil
Relinor
Mapo

Generate five sentences from a translation of the Code of Hammurabi:

require 'chain_punk'

text = IO.read('docs/code_of_hammurabi.txt')
corpus = ChainPunk::Corpus.new(text, boundaries: [' '], closures: ['.', ';'])
generator = ChainPunk::Generator.new(corpus.frequency_table)
[*1..5].each { puts generator.generate(rand(4..8),  boundary: ' ') }

Outputs:

Dam-gal-nunna, who supplied water
protected the divine city
scepter and promoted the weak,
put into execution the
settlement of all mankind to shine brilliantly

See the example app for more examples.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/molenick/chain_punk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

Before submitting a pull request, please:

  1. Write tests to cover your work.
  2. Run rake spec to run the tests.
  3. Run bundle exec rubocop and fix any issues.

Code of Conduct

Everyone interacting in the ChainPunk project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.