Here's a little something i tried yesterday: a ruby script that mixes and matches verbs, nouns, adjectives, and colors to come up with crazy ass lyrics, red hot style. Enjoy :)
$nouns = IO.readlines('names.txt')
$adjectives = IO.readlines('adjectives.txt')
$verbs = IO.readlines('verbs.txt')
$adjectives << ['red','blue','green','white','black','yellow','brown','gray']
$pronouns = IO.readlines('pronouns.txt')
$adverbs = IO.readlines('adverbs.txt')
$prepositions = IO.readlines('prepositions.txt')
def getrand(collection)
sleep rand / 10000
collection[rand * collection.length.toi - 1]
end
def prepositionphrase
"#{getrand($prepositions).strip} the #{get_rand($nouns).strip}"
end
def adjectivatedsubjectphrase
thepart = "the" if rand.tof > 0.5
adjective = getrand($adjectives).strip if rand.tof > 0.5
return "#{thepart} #{adjective} #{getrand($nouns).strip}" if the_part and adjective
nil
end
def generatephrase
as = adjectivatedsubjectphrase
adjectivatedsubjectpart = as.nil? ? getrand($pronouns).strip : as
prepositionpart = rand.tof > 0.5 ? prepositionphrase : ""
verbpart = getrand($verbs).strip
objectpart = rand.tof > 0.25 ? getrand($nouns).strip : ""
thepart = (rand.tof > 0.5 and objectpart != "") ? "the" : ""
adverbpart = rand.tof > 0.75 ? getrand($adverbs).strip : ""
"#{adjectivatedsubjectpart} #{prepositionpart} #{verbpart} #{thepart} #{objectpart} #{adverb_part}".squeeze(" ").strip
end
def generatelyrics
result = ""
(1..5).each do
firstphrase = generatephrase
newphrase = generatephrase
while newphrase[-2, 2] != firstphrase[-2, 2] or newphrase.split(" ")[-1] == firstphrase.split(" ")[-1] do
newphrase = generatephrase
end
result << "#{firstphrase}\r\n#{new_phrase}\r\n\r\n"
end
result
end
puts generatelyrics
Here are the sources: <a href=“http://pedroassuncao.com/wp-content/uploads/2011/11/rhcplyricsv2.tar.gz”>rhcplyrics_v2.tar. As a bonus there is a script to see how many attempts are required to reach the phrase “The quick brown fox” :)