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 when tokenizing #66

Open
aliw77 opened this issue Nov 23, 2013 · 3 comments
Open

Comments

@aliw77
Copy link

aliw77 commented Nov 23, 2013

Running through a few examples from the manual, cannot get tokenize to work. Here is a paste from irb:

2.0.0p195 :005 > require 'treat'
 => false
2.0.0p195 :006 > include Treat::Core::DSL
 => Object
2.0.0p195 :007 > p = paragraph('A walk in the park. A trip on a boat.').segment
 => Paragraph (70247709531120)  --- "A walk in [...] a boat."  ---  {}   --- []
2.0.0p195 :023 > Treat.core.language.detect = true
 => true
2.0.0p195 :035 > sent = "This is an English sentence, prove it to me!"
 => "This is an English sentence, prove it to me!"
2.0.0p195 :036 > sent.apply(:tokenize, :parse).print_tree
TypeError: no implicit conversion from nil to integer
    from /Users/mac/.rvm/gems/ruby-2.0.0-p195/gems/treat-2.0.7/lib/treat/entities/entity/delegatable.rb:91:in `[]'
    from /Users/mac/.rvm/gems/ruby-2.0.0-p195/gems/treat-2.0.7/lib/treat/entities/entity/delegatable.rb:91:in `find_worker_for_language'
    from /Users/mac/.rvm/gems/ruby-2.0.0-p195/gems/treat-2.0.7/lib/treat/entities/entity/delegatable.rb:83:in `find_worker'
    from /Users/mac/.rvm/gems/ruby-2.0.0-p195/gems/treat-2.0.7/lib/treat/entities/entity/delegatable.rb:55:in `call_worker'
    from /Users/mac/.rvm/gems/ruby-2.0.0-p195/gems/treat-2.0.7/lib/treat/entities/entity/delegatable.rb:40:in `block (2 levels) in add_workers'
    from /Users/mac/.rvm/gems/ruby-2.0.0-p195/gems/treat-2.0.7/lib/treat/entities/entity/applicable.rb:41:in `do_task'
    from /Users/mac/.rvm/gems/ruby-2.0.0-p195/gems/treat-2.0.7/lib/treat/entities/entity/applicable.rb:22:in `block in apply'
    from /Users/mac/.rvm/gems/ruby-2.0.0-p195/gems/treat-2.0.7/lib/treat/entities/entity/applicable.rb:6:in `each'
    from /Users/mac/.rvm/gems/ruby-2.0.0-p195/gems/treat-2.0.7/lib/treat/entities/entity/applicable.rb:6:in `apply'
    from /Users/mac/.rvm/gems/ruby-2.0.0-p195/gems/treat-2.0.7/lib/treat/proxies/proxy.rb:14:in `method_missing'
    from (irb):36
    from /Users/mac/.rvm/rubies/ruby-2.0.0-p195/bin/irb:16:in `<main>'
@louismullie
Copy link
Owner

This seems like it's the language detection feature causing the bug. Does the bug disappear if you remove Treat.core.language.detect = true ?

@aliw77
Copy link
Author

aliw77 commented Nov 26, 2013

I actually wanted to use the treat gem for language detection of user text input. Without language detection i get "english" for all sentences. e.g.

2.0.0p195 :009 > puts "El mundo de hoy no tiene sentido".language
english
 => nil

@nightscape
Copy link

Has anyone found a solution to this? On my Mac language recognition doesn't seem to work:

Treat.core.language.detect = true
a = "I want to know God's thoughts; the rest are details. - Albert Einstein"
b = "El mundo de hoy no tiene sentido, así que ¿por qué debería pintar cuadros que lo tuvieran? - Pablo Picasso"
c = "Un bon Allemand ne peut souffrir les Français, mais il boit volontiers les vins de France. - Goethe"
d = "Wir haben die Kunst, damit wir nicht an der Wahrheit zugrunde gehen. - Friedrich Nietzsche"
puts a.language    # => nil
puts b.language    # => nil
puts c.language    # => nil
puts d.language    # => nil

Before that I did a

require 'treat'
Treat::Core::Installer.install
Treat::Core::Installer.install 'german'

Is there something else required for language recognition to work?

louismullie added a commit that referenced this issue Feb 19, 2014
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