class DuckLingo::LearnLang
Public Class Methods
duck_search()
click to toggle source
Searches online for a new word.
# File lib/DuckLingo.rb, line 9 def self.duck_search # learns data require "duck_duck_go" old_information = File.read("data/information.txt").strip print "What information do you want to teach? >> " teach_info = gets.chomp ddg = DuckDuckGo.new zci = ddg.zeroclickinfo("#{teach_info}") open("data/information.txt", "w") { |f| # f.puts zci.heading f.puts zci.abstract_text f.puts zci.related_topics["_"][0].text f.puts old_information } end
invent_usage()
click to toggle source
Invents a new purpose for things.
# File lib/DuckLingo.rb, line 43 def self.invent_usage system("clear") require "gabbler" gabbler = Gabbler.new user_iterate = File.read("data/iterations.txt").strip.to_i information = File.read('data/information.txt') gabbler.learn(information) user_iterate.times do puts gabbler.sentence end end
spout_gabble()
click to toggle source
Teaches the correct usage of a word.
# File lib/DuckLingo.rb, line 30 def self.spout_gabble # spouts data system("clear") user_iterate = File.read("data/iterations.txt").strip.to_i information = File.readlines('data/information.txt') user_iterate.times do puts information.sample end end