The Red Hot Chili Peppers Lyrics Generator
everything of the pigs rid seed whom plan the need ourselves plead glove himself love the macho crowd of the plants design the map my stamp cap me inventory table whoever like the laugh wriggle they announce the beginner upbeat few toward the acoustics summarize the cat
For an explanation on how this works, feel free to read this blog post and download the sources, or check out the source code below.
Source code for this experiment
Show/hide
class RhcpLyricsGeneratorController < ApplicationController def get_rand(collection) sleep rand / 10000 collection[rand * collection.length.to_i - 1] end def preposition_phrase "#{get_rand(PREPOSITIONS).strip} the #{get_rand(NOUNS).strip}" end def adjectivated_subject_phrase the_part = "the" if rand.to_f > 0.5 adjective = get_rand(ADJECTIVES).strip if rand.to_f > 0.5 return "#{the_part} #{adjective} #{get_rand(NOUNS).strip}" if the_part and adjective nil end def generate_phrase as = adjectivated_subject_phrase adjectivated_subject_part = as.nil? ? get_rand(PRONOUNS).strip : as preposition_part = rand.to_f > 0.5 ? preposition_phrase : "" verb_part = get_rand(VERBS).strip object_part = rand.to_f > 0.25 ? get_rand(NOUNS).strip : "" the_part = (rand.to_f > 0.5 and object_part != "") ? "the" : "" adverb_part = rand.to_f > 0.75 ? get_rand(ADVERBS).strip : "" "#{adjectivated_subject_part} #{preposition_part} #{verb_part} #{the_part} #{object_part} #{adverb_part}".squeeze(" ").strip end def generate_lyrics result = "" (1..5).each do first_phrase = generate_phrase new_phrase = generate_phrase while new_phrase[-2, 2] != first_phrase[-2, 2] or new_phrase.split(" ")[-1] == first_phrase.split(" ")[-1] do new_phrase = generate_phrase end result << "#{first_phrase} #{new_phrase} " end result end def index @lyrics = generate_lyrics end end