これがまったくの初心者の質問である場合は申し訳ありませんが、この問題を解決する方法がわかりません。以下のコードを実行しようとすると、現在これらのエラーが発生しています。
bot.rb:58:in `rescue in initialize': Can't load bot data (RunTimeError)
bot.rb:55:in `initialize'
basic_client.rb:3:in `new'
basic_client.rb:3:in `<top (required)>'
こちらがbot.rbのソースコードで、「@data = YAML.load(File.open(options[:data_file]).read)」の部分にエラーが出ているようです。
# A basic implementation of a chatterbot
class Bot
attr_reader :name
# Initializes the bot object, loads in the external YAML data
# file and sets the bot's name. Raises an exception if
# the data loading process fails.
def initialize(options)
@name = options[:name] || "Unnamed Bot"
begin
@data = YAML.load(File.open(options[:data_file]).read)
rescue
raise "Can't load bot data"
end
end
これは、basic_client.rb ファイルのソース コードです。
require './bot'
bot = Bot.new(:name => ARGV[0], :data_file => ARGV[1])
puts bot.greeting
while input = $stdin.gets and input.chomp != 'end'
puts '>> ' + bot.response_to(input)
end
puts bot.farewell
誰かが私を助けることができれば、それは素晴らしいことです. また、問題に関してさらに詳しい情報や説明が必要な場合は、それも提供できます。
ありがとうございました!