Skip to content

Commit 28d31c1

Browse files
committed
Upgrade kanye generator to use new retort_api gem
1 parent 03b3d3e commit 28d31c1

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

kanye.rb

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'httparty'
1+
require 'retort_api'
22
require 'rhymes'
33

44
rhyme_schemes = {
@@ -16,21 +16,12 @@
1616

1717
# Generate a random word that we've seen Kanye use prior to the given word
1818
def previous_word after
19-
url = "http://www.retort.us/bigram/prior?after=#{after}&medium=bible"
20-
json = JSON.parse(HTTParty.get(url).body)
21-
22-
puts "#{json['prior']} --> #{after}"
23-
24-
json["prior"]
25-
rescue
26-
puts "No words found prior to #{after}"
27-
nil
19+
RetortApi.get_word_before(after, identity: { medium: 'bible' })
2820
end
2921

3022
# Generate a fully random line
3123
def full_line
32-
url = "http://www.retort.us/markov/create?medium=bible"
33-
HTTParty.get(url).body
24+
RetortApi.markov_chain(identity: { medium: 'bible' })
3425
end
3526

3627
# Returns all possible rhymes for a word

0 commit comments

Comments
 (0)