我正在尝试在 Ruby 中使用 narray 运行 kmeans-clusterer。但是当谈到 narray_ext.rb 中的这一行时:
na = self.new(type,*shape)
我收到此错误:
narray_ext.rb:21:innew': Argument required (ArgumentError)
我正在使用这些宝石:
- kmeans-clusterer-0.11.4
- narray-0.6.1.2
- 僵尸作家-0.2.0
堆栈跟踪:
/home/mikael/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/narray-0.6.1.2/narray/narray_ext.rb:21:in `new': Argument required (ArgumentError)
from /home/mikael/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/narray-0.6.1.2/narray/narray_ext.rb:21:in `cast'
from /home/mikael/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/kmeans-clusterer-0.11.4/lib/kmeans-clusterer.rb:13:in `ensure_matrix'
from /home/mikael/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/kmeans-clusterer-0.11.4/lib/kmeans-clusterer.rb:130:in `run'
from /home/mikael/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:80:in `generate_clusters'
from /home/mikael/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/zombie_writer-0.2.0/lib/zombie_writer.rb:56:in `generate_articles'
from main.rb:17:in `<main>'
我的代码:
require 'zombie_writer'
zombie = ZombieWriter::MachineLearning.new
zombie.add_string(content: "Lorem ipsum dolor sit amet.",
sourcetext: "Cicero's Great Speech On Ethics",
sourceurl: "http://example.com/lorem-ipsum")
array = zombie.generate_articles
我自己对 Ruby 来说还很陌生,所以我想不通。有谁知道发生了什么以及我该如何解决?