2012-10-13 71 views
1

我正在嘗試在我正在使用的紅寶石項目中使用Ankusa(https://github.com/livingsocial/ankusa)gem。即使使用寶石,Ruby'未初始化常量'錯誤

我運行下面的代碼安裝了ankusa寶石,但我仍然得到一個錯誤: 未初始化的常量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 

任何幫助將不勝感激。

回答

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' 
+0

感謝的作品。我需要'ankusa'和'ankusa/memory_storage' – AFraser

相關問題