Open gabro opened 10 years ago
I'm seeing the same thing. Did you find a solution to this?
I can't reproduce with my p392. Will investigate with the newer version...
It looks like something with the latest StanfordCoreNLP. I'm not sure at this point but I did try to install your other gem (sfanford-core-nlp) and it took a lot of odd manual configuration to get running.
I'll post a better report when I get to my computer (versions, os etc)
I just got this with treat (2.0.7) with the automatic installer.
has anyone managed to fix this one?
still not working.
2.1.2 :001 > require 'treat'
=> true
2.1.2 :002 > require 'stanford-core-nlp'
=> true
2.1.2 :003 > sent = "This is an English sentence, prove it to me!"
=> "This is an English sentence, prove it to me!"
2.1.2 :004 > sent.apply(:parse).print_tree
NoMethodError: undefined method children' for nil:NilClass from /home/shadowserv/.rvm/gems/ruby-2.1.2/gems/treat-2.1.0/lib/treat/workers/processors/parsers/stanford.rb:57:in
recurse'
from /home/shadowserv/.rvm/gems/ruby-2.1.2/gems/treat-2.1.0/lib/treat/workers/processors/parsers/stanford.rb:50:in parse' from /home/shadowserv/.rvm/gems/ruby-2.1.2/gems/treat-2.1.0/lib/treat/entities/entity/delegatable.rb:66:in
call_worker'
from /home/shadowserv/.rvm/gems/ruby-2.1.2/gems/treat-2.1.0/lib/treat/entities/entity/delegatable.rb:40:in block (2 levels) in add_workers' from /home/shadowserv/.rvm/gems/ruby-2.1.2/gems/treat-2.1.0/lib/treat/entities/entity/applicable.rb:41:in
do_task'
from /home/shadowserv/.rvm/gems/ruby-2.1.2/gems/treat-2.1.0/lib/treat/entities/entity/applicable.rb:22:in block in apply' from /home/shadowserv/.rvm/gems/ruby-2.1.2/gems/treat-2.1.0/lib/treat/entities/entity/applicable.rb:6:in
each'
from /home/shadowserv/.rvm/gems/ruby-2.1.2/gems/treat-2.1.0/lib/treat/entities/entity/applicable.rb:6:in apply' from /home/shadowserv/.rvm/gems/ruby-2.1.2/gems/treat-2.1.0/lib/treat/proxies/proxy.rb:14:in
method_missing'
from (irb):4
from /home/shadowserv/.rvm/rubies/ruby-2.1.2/bin/irb:11:in `
ls $GEM_HOME/gems/stanford-core-nlp-0.5.1/bin AnnotationBridge.java bridge.jar joda-time.jar jollyday.jar stanford-corenlp.jar stanford-parser.jar stanford-segmenter.jar xom.jar
Are you using the latest version of StanfordCoreNLP files from the Stanford website, or are you downloading from my website (linked in the Manual)?
Also, can you please test on 1.9.3.xxx and let me know if the bug reproduces there?
I get the same thing with ruby 1.9.3:
1.9.3-p547 :001 > require 'treat'
=> true
1.9.3-p547 :002 > include Treat::Core::DSL
=> Object
1.9.3-p547 :003 > 'A strong wind would take you away'.apply(:parse).print_tree
NoMethodError: undefined method `children' for nil:NilClass
from /Users/brian/.rvm/gems/ruby-1.9.3-p547/gems/treat-2.1.0/lib/treat/core/dsl.rb:17:in `method_missing'
from /Users/brian/.rvm/gems/ruby-1.9.3-p547/gems/treat-2.1.0/lib/treat/workers/processors/parsers/stanford.rb:57:in `recurse'
from /Users/brian/.rvm/gems/ruby-1.9.3-p547/gems/treat-2.1.0/lib/treat/workers/processors/parsers/stanford.rb:50:in `parse'
from /Users/brian/.rvm/gems/ruby-1.9.3-p547/gems/treat-2.1.0/lib/treat/entities/entity/delegatable.rb:66:in `call_worker'
from /Users/brian/.rvm/gems/ruby-1.9.3-p547/gems/treat-2.1.0/lib/treat/entities/entity/delegatable.rb:40:in `block (2 levels) in add_workers'
from /Users/brian/.rvm/gems/ruby-1.9.3-p547/gems/treat-2.1.0/lib/treat/entities/entity/applicable.rb:41:in `do_task'
from /Users/brian/.rvm/gems/ruby-1.9.3-p547/gems/treat-2.1.0/lib/treat/entities/entity/applicable.rb:22:in `block in apply'
from /Users/brian/.rvm/gems/ruby-1.9.3-p547/gems/treat-2.1.0/lib/treat/entities/entity/applicable.rb:6:in `each'
from /Users/brian/.rvm/gems/ruby-1.9.3-p547/gems/treat-2.1.0/lib/treat/entities/entity/applicable.rb:6:in `apply'
from /Users/brian/.rvm/gems/ruby-1.9.3-p547/gems/treat-2.1.0/lib/treat/proxies/proxy.rb:14:in `method_missing'
from (irb):3
from /Users/brian/.rvm/rubies/ruby-1.9.3-p547/bin/irb:12:in `<main>'
(and 2.1.2, which is what I tried first)
Getting this same error, did anyone find a solution yet?
I ended up using https://github.com/louismullie/stanford-core-nlp directly
@cheerfulstoic I just downloaded that myself
Same issue. I can get Stanford Core NLP running on my machine, but unfortunately I can't get Treat to parse on either 1.9.3 or 2.1.4.
Here's what I'm seeing:
2.1.4 :001 > require 'treat'
2.1.4 :002 > sent = "This is an English sentence, prove it to me!"
2.1.4 :003 > sent.apply(:parse).print_tree
NoMethodError: undefined method `children' for nil:NilClass
from ~/.rvm/gems/ruby-2.1.4@nlp/gems/treat-2.1.0/lib/treat/workers/processors/parsers/stanford.rb:57:in `recurse'
~/.rvm/gems/ruby-2.1.4@nlp/gems/treat-2.1.0/lib/treat/workers/processors/parsers/stanford.rb @ line 50 Treat::Workers::Processors::Parsers::Stanford.parse:
Specifically, I think the failure occurs a little further up the chain at Treat::Workers::Processors::Parsers::Stanford#parse
on line 48-49 of stanford.rb
(above):
48: text = parser.apply(list)
49: recurse(text.children[0], entity, tag_set)
Since parser.apply(list)
returns an empty Rjb::Rjb_JavaProxy
, calling text.children
results in an empty array []
, and text.children[0]
results in a nil
that eventually ends up in the #recurse
method with undefined method 'children' for nil:NilClass
.
I'm unclear whether it's a problem with the list
variable or whether it's something that's occurring in either the bind-it
or rjb
gems that send the data to the parser.
Any ideas why parser.apply(list)
would be returning an empty object?
Ok, so this is interesting. If I tokenize first, then parsing appears to be working. For example:
FAILS:
Calling parse
directly on the string.
2.1.4 :001 > 'This is an English sentence, prove it to me!'.parse.print_tree
NoMethodError: undefined method `children' for nil:NilClass
from ~/.rvm/gems/ruby-2.1.4@nlp/gems/treat-2.1.0/lib/treat/workers/processors/parsers/stanford.rb:57:in `recurse'
WORKS:
Adding tokenize
before the parse
method.
2.1.4 :001 > 'This is an English sentence, prove it to me!'.tokenize.parse.print_tree
+ Sentence (70142349342820) --- "This is an [...] to me!" --- {:tag_set=>:penn} --- []
|
+--+ Phrase (70142349274320) --- "This" --- {:tag=>"NP"} --- []
...
+--> Punctuation (70142352605260) --- "!" --- {:tag=>"."} --- [
Not sure why, but that seems to work.
@ojak - indeed, as per the manual the parser requires tokenization. However it seems like the OP was appropriately tokenizing the sentences and still running into issues.
@louismullie - I see, so the OP's problem is different from the others (and mine).
FYI, I was also unable to reproduce the OP's error on ruby 2.1.4, treat 2.1.0, and stanford-core-nlp 0.5.1 with the complete JAR installed under RVM.
@gabro @acrookston - Does stanford-core-nlp
work for you outside of treat? From IRB, can you run the following without receiving an error (to ensure that the JAR's are working for you):
2.1.4 :001 > require 'stanford-core-nlp'
2.1.4 :002 > pipeline = StanfordCoreNLP.load(:tokenize, :ssplit, :pos, :lemma, :parse, :ner, :dcoref)
Seeing this issue too.
same here
sent = "Just a test"
sent.apply(:parse).print_tree
NoMethodError: undefined method `children' for nil:NilClass
from /Users/christinebooher/.rvm/gems/ruby-2.2.2@improvement.rocks/gems/treat-2.1.0/lib/treat/core/dsl.rb:17:in `method_missing'
from /Users/christinebooher/.rvm/gems/ruby-2.2.2@improvement.rocks/gems/treat-2.1.0/lib/treat/workers/processors/parsers/stanford.rb:57:in `recurse'
I had the same problem, and preforming tokenization before parsing did resolved the problem. That makes sense as a pipeline, but as is the documentation doesn't explain it. On the contrary, it propose the example which was pasted here several time which skip the tokenization.
The code should seamlessly run tokenize
if needed and possible when the entity is parsed, so the documentation would be correct. Or an other option would be to let the documentation as is and catch this kind of exception when attempting to parse and throw relevant information about the mandatoriness of tokenizing before parsing.
I'm trying to parse a document, but I get this error. Here's my code attempt
And here's the stacktrace
I used the automatic installer and manually installed Enju, which is in my PATH.
Any idea on why I'm getting such error?