0.06
Low commit activity in last 3 years
A long-lived project that still receives updates
Generate a random English adjective-noun word pair.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Development

~> 5.10

Runtime

~> 2.3
 Project Readme

Spicy::Proton

Generate a random English adjective-noun word pair. Works with Ruby 1.9.x and newer.

Gem Version Build Status

Quick Start

gem install spicy-proton

require 'spicy-proton'

puts Spicy::Proton.pair
# => "decadent-inquisition"

Usage

Option 1: Class methods

When generating single or infrequent specimens, class methods are faster and use less memory.

require 'spicy-proton'

Spicy::Proton.adjective             # => "extreme"
Spicy::Proton.noun                  # => "loan"
Spicy::Proton.pair                  # => "opportune-spacesuit"
Spicy::Proton.pair(':')             # => "hip:squash"
Spicy::Proton.adverb                # => "energetically"
Spicy::Proton.verb                  # => "refrained"
Spicy::Proton.format('%a/%a/%n')    # => "dapper/festive/fedora"
Spicy::Proton.format('%b %v')       # => "artfully stained"

# With length constraints.
Spicy::Proton.adjective(max: 5)     # => "dank"
Spicy::Proton.noun(min: 10)         # => "interpolation"
Spicy::Proton.adjective(length: 8)  # => "medieval"
Spicy::Proton.noun(min: 5, max: 7)  # => "dolphin"
Spicy::Proton.adverb(min: 0)        # => "prophetically"
Spicy::Proton.verb(max: 100)        # => "sparkles"

Option 2: Instance methods

When generating multiple specimens, instance methods are faster. The instance keeps the word corpus in memory. The instance methods are the same as their class method counterparts.

require 'spicy-proton'

gen = Spicy::Proton.new
1000.times do 
  gen.adjective
  gen.noun(min: 7)
  gen.pair
  gen.pair('.')
  gen.adverb(length: 6)
  gen.verb(max: 5)
  gen.format('The %a %n %b %v the %n.')
end

Instances also provide raw word lists in length order:

gen.adjectives    # => ["aft", "apt", "bad", "big", ...]
gen.nouns         # => ["ad", "ax, "ox", "pi", ...]
gen.adverbs       # => ["no", "aft", "ago", "all", ...]
gen.verbs         # => ["am", "be", "do", "go", ...]

Credits

Inspired by btford/adj-noun. Thanks to NLTK for the word corpus.

License

Copyright © 2017 Chris Schmich
MIT License. See LICENSE for details.