即使需要gem,Ruby'未初始化的常量'错误

时间:2012-10-13 07:21:25

标签: ruby rubygems require

我试图在我正在处理的红宝石项目中使用Ankusa(https://github.com/livingsocial/ankusa)gem。

我安装了ankusa gem后运行下面的代码,但我仍然收到错误消息:     未初始化的常量Ankusa :: MemoryStorage(NameError)

require 'rubygems'
require 'ankusa'
require 'ankusa/hbase_storage'

storage = Ankusa::MemoryStorage.new
c = Ankusa::NaiveBayesClassifier.new storage

c.train :spam, "This is some spammy text"
c.train :good, "This is not the bad stuff"

puts c.classify "This is some spammy text"

puts c.classifications "This is some spammy text"

puts c.log_likelihoods "This is some spammy text"

puts c.classnames
storage.close

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:2)

查看gem文件夹中的ankusa.rb。它只需要以下内容:

require 'ankusa/version'
require 'ankusa/extensions'
require 'ankusa/classifier'
require 'ankusa/naive_bayes'
require 'ankusa/kl_divergence'
require 'ankusa/hasher'

所以,您可能需要明确要求

require 'ankusa/memory_storage'