Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: no implicit conversion from nil to integer in /classifier-reborn-2.2.0/lib/classifier-reborn/lsi.rb:313:in `sort' #184

Open
stephenhmarsh opened this issue May 11, 2019 · 2 comments

Comments

@stephenhmarsh
Copy link

terms = %w(artist_name artist_years art_title signature_info medium dimensions dimensions art_created_year) 

lsi = ClassifierReborn::LSI.new

array = ["Jean Arp", "1886 - 1966", "FIGURE-GERME DITE \"L'APRÈS-MIDINETTE\"", "Stamped with the raised initials HA and numbered V/V (on the interior)", "Bronze", "Height: 32 in.", "81.3 cm", "Conceived in 1958-59; this example cast by Georges Rudier in 1964."]

array.each_with_index do |text, index|
  lsi.add_item(text, terms[index])
end

throws:

TypeError: no implicit conversion from nil to integer
from /Users/stephen/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/classifier-reborn-2.2.0/lib/classifier-reborn/lsi.rb:313:in `sort'

trace:

wtf?
Exception: TypeError: no implicit conversion from nil to integer
--
0: /Users/stephen/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/classifier-reborn-2.2.0/lib/classifier-reborn/lsi.rb:313:in `sort'
1: /Users/stephen/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/classifier-reborn-2.2.0/lib/classifier-reborn/lsi.rb:313:in `build_reduced_matrix'
2: /Users/stephen/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/classifier-reborn-2.2.0/lib/classifier-reborn/lsi.rb:143:in `build_index'
3: /Users/stephen/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/classifier-reborn-2.2.0/lib/classifier-reborn/lsi.rb:77:in `add_item'
4: (pry):130:in `block in __pry__'
5: (pry):129:in `each'
6: (pry):129:in `each_with_index'
7: (pry):129:in `__pry__'
8: /Users/stephen/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/pry_instance.rb:387:in `eval'
9: /Users/stephen/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/pry-0.12.2/lib/pry/pry_instance.rb:387:in `evaluate_ruby'

object:

lsi
=> #<ClassifierReborn::LSI:0x00007f98966163f0
 @auto_rebuild=true,
 @built_at_version=-1,
 @cache_node_vectors=nil,
 @items=
  {"Jean Arp"=>#<ClassifierReborn::ContentNode:0x00007f98953ad5b0 @categories=["artist_name"], @lsi_norm=nil, @lsi_vector=nil, @raw_norm=Vector[0.7071067811865475, 0.7071067811865475, 0.0, 0.0], @raw_vector=Vector[1.0, 1.0, 0.0, 0.0], @word_hash={:jean=>1, :arp=>1}>,
   "1886 - 1966"=>
    #<ClassifierReborn::ContentNode:0x00007f98953ad290 @categories=["artist_years"], @lsi_norm=nil, @lsi_vector=nil, @raw_norm=Vector[0.0, 0.0, 0.7071067811865475, 0.7071067811865475], @raw_vector=Vector[0.0, 0.0, 1.0, 1.0], @word_hash={:"1886"=>1, :"1966"=>1}>},
 @language="en",
 @version=2,
 @word_list=#<ClassifierReborn::WordList:0x00007f98953ad240 @location_table={:jean=>0, :arp=>1, :"1886"=>2, :"1966"=>3}>>
@Ch4s3
Copy link
Member

Ch4s3 commented Sep 26, 2019

@stephenhmarsh This is a bug that has existed since the original implementation that as resisted numerous attempts to fix it. I could be because you input is too short for lsi, but I'm not sure.

@otaviogaiao
Copy link

I'm facing this bug too. Any idea on what to do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants