Calais Gem无法将nil转换为String

时间:2013-04-23 17:04:24

标签: ruby opencalais

我在Ruby 1.9.3中使用Calais gem,当我使用以下代码片段时:

   rdf = Calais.process_document(
       :content => text,
       :content_type => :html,
       :license_id => 'xxxxxxxxxxxxxxxxxxxxxx',
       # :output_format => :json,
       :metadata_enables => ["SocialTags"]

   )

我确信文本在那里。堆栈跟踪如下。有谁知道可能有什么不妥?

Completed 500 Internal Server Error in 39423ms

TypeError - can't convert nil into String:
  (gem) calais-0.0.13/lib/calais/response.rb:92:in `parse'
  (gem) calais-0.0.13/lib/calais/response.rb:92:in `block in extract_data'
  (gem) nokogiri-1.5.6/lib/nokogiri/xml/node_set.rb:239:in `block in each'
  (gem) nokogiri-1.5.6/lib/nokogiri/xml/node_set.rb:238:in `upto'
  (gem) nokogiri-1.5.6/lib/nokogiri/xml/node_set.rb:238:in `each'
  (gem) calais-0.0.13/lib/calais/response.rb:90:in `extract_data'
  (gem) calais-0.0.13/lib/calais/response.rb:29:in `initialize'
  (gem) calais-0.0.13/lib/calais.rb:56:in `new'
  (gem) calais-0.0.13/lib/calais.rb:56:in `process_document'

1 个答案:

答案 0 :(得分:3)

这似乎是加莱宝石的一个问题,可能是新版本的nokigiri。

尝试this fork提交显示已修复了nokogiri 1.5.6问题。

https://github.com/bborn/calais/commits/master