1

我正在尝试在我正在处理的 ruby​​ 项目中使用 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

任何帮助将不胜感激。

4

1 回答 1

2

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

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

因此,您可能需要明确要求它

require 'ankusa/memory_storage'
于 2012-10-13T07:33:03.433 回答