Generate a random English adjective-noun word pair. Works with Ruby 1.9.x and newer.
gem install spicy-proton
require 'spicy-proton'
puts Spicy::Proton.pair
# => "decadent-inquisition"
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-alphabetic 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", ...]
Inspired by btford/adj-noun. Thanks to NLTK for the word corpus.
Copyright © 2017 Chris Schmich
MIT License. See LICENSE for details.