louismullie / stanford-core-nlp

Ruby bindings to the Stanford Core NLP tools (English, French, German).
Other
432 stars 70 forks source link

Cant create JVM Error #13

Open avinashmkb opened 11 years ago

avinashmkb commented 11 years ago

I have installed RJB and the followed all instructions as suggested in your gem documentation.

Have installed JAVA 1.6 and set the $JAVA_HOME TO /home/avinash/jdk1.6.0_38 similarly i have set $LD_LIBRARY_PATH=/home/avinash/jdk1.6.0_38/lib

Also defined Ruby Enviroment variables

ENV['JAVA_HOME'] = "/home/avinash/jdk1.6.0_38" ENV['LD_LIBRARY_PATH']="/home/avinash/jdk1.6.0_38/lib"

[root@avinash shoutout_railsengine]# IRB -bash: IRB: command not found [root@avinash shoutout_railsengine]# irb irb(main):001:0> require 'stanford-core-nlp' => true irb(main):002:0> StanfordCoreNLP.log_file = 'log.txt' => "log.txt" irb(main):003:0> StanfordCoreNLP.set_model('pos.model', 'english-left3words-distsim.tagger') => "taggers/english-left3words-distsim.tagger" irb(main):004:0> text = 'Angela Merkel met Nicolas Sarkozy on January 25th in ' => "Angela Merkel met Nicolas Sarkozy on January 25th in " irb(main):005:0> pipeline = StanfordCoreNLP.load(:tokenize, :ssplit, :pos, :lemma, :parse, :ner, :dcoref) RuntimeError: can't create Java VM from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/jar_loader.rb:19:in load' from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/jar_loader.rb:19:ininit' from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/jar_loader.rb:36:in load' from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/binding.rb:56:inload_jar' from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/binding.rb:64:in block in load_default_jars' from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/binding.rb:61:ineach' from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/binding.rb:61:in load_default_jars' from /usr/local/lib/ruby/gems/1.9.1/gems/bind-it-0.2.0/lib/bind-it/binding.rb:48:inbind' from /usr/local/lib/ruby/gems/1.9.1/gems/stanford-core-nlp-0.3.5/lib/stanford-core-nlp.rb:118:in load' from (irb):5 from /usr/local/bin/irb:12:in

'

louismullie commented 11 years ago

@avinashmkb Are you able to creata a Java VM from scratch outside of the gem, using Rjb? What does the following output?

$DEBUG=true
require 'rjb'
Point = Rjb::import('java.awt.Point')
p = Point.new(0, 0)
p.y = 80
puts "x=#{p.x}, y=#{p.y}" # => "0,80"
avinashmkb commented 11 years ago

Guess the JAVA VM does not get created using RJB itself , so the problem is not with stanford nlp gem :( irb(main):005:0> Point = Rjb::import('java.awt.Point') Exception RuntimeError' at (irb):5 - can't create Java VM ExceptionRuntimeError' at /usr/local/lib/ruby/1.9.1/irb/workspace.rb:80 - can't create Java VM RuntimeError: can't create Java VM from (irb):5:in import' from (irb):5 from /usr/local/bin/irb:12:in

'

avinashmkb commented 11 years ago

Hi I managed to solve the issue with RJB and now RJB is working but still i get the below error in irb

ubuntu@ip-10-130-70-172:~/shoutout_web$ irb 1.9.3-p194 :001 > require 'stanford-core-nlp' => true 1.9.3-p194 :002 > pipeline = StanfordCoreNLP.load(:tokenize, :ssplit, :pos, :lemma, :parse, :ner, :dcoref) RuntimeError: Could not find JAR file (looking in joda-time.jar). from /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/gems/bind-it-0.2.1/lib/bind-it/jar_loader.rb:20:in load' from /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/gems/bind-it-0.2.1/lib/bind-it/binding.rb:65:inload_jar' from /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/gems/bind-it-0.2.1/lib/bind-it/binding.rb:73:in block in load_default_jars' from /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/gems/bind-it-0.2.1/lib/bind-it/binding.rb:70:ineach' from /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/gems/bind-it-0.2.1/lib/bind-it/binding.rb:70:in load_default_jars' from /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/gems/bind-it-0.2.1/lib/bind-it/binding.rb:57:inbind' from /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/gems/stanford-core-nlp-0.4.1/lib/stanford-core-nlp.rb:125:in load' from (irb):2 from /home/ubuntu/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in

'

The file joda-time.jar is located in the gem's bin directory

lramach commented 11 years ago

Do you have multiple versions of the stanford-core-nlp gem? Then maybe the jar is in one of the alternate version's bin folder. Did you happen to check this?

louismullie commented 11 years ago

Yes, that may be the problem. You need to copy the files from one version's folder to the other.

louismullie commented 11 years ago

Also, #14 may have affected you.

avinashmkb commented 11 years ago

Yes it is now fixed thanks a lot !

louismullie commented 11 years ago

OK great!

lramach commented 11 years ago

I thought I had the JVM error fixed, but when I ran my app today I got the can't create Java VM error on the stanford-core-nlp-0.3.0 gem.

Infact when I ran pipeline = StanfordCoreNLP.load(:tokenize, :ssplit, :pos, :lemma, :parse, :ner, :dcoref) on the console I got a Segmentation fault.

The JVM seems to be getting created correctly for rjb (on the console), but is throwing this error for the StanfordCoreNLP gem.

Would you happen to have any suggestions? Thanks!

louismullie commented 11 years ago

Can you please update to the latest version of the gem and try with that?

lramach commented 11 years ago

I saw that you'd reported that the JVM error could be caused by insufficient RAM.

I think this could be the cause, since our app was moved to a new server recently. I have to check with my professor before increasing the memory available to the application.

louismullie commented 11 years ago

OK! Please do report back when you have a chance.

lramach commented 11 years ago

The system has about 151MB free, and when I looked up Stanford NLP's page I found that it would need at least 2GB of memory. Could this probably be why I am getting the segmentation fault also, due to insufficient memory?

louismullie commented 11 years ago

I don't know the ins and outs of Rjb; it is possibly related, but I doubt that's the problem. My gut feeling is that you updated the gem but not the model files.

Otherwise, can you narrow down the problem a bit? Does it occur only when you try to load all annotators at once, or does it occur regardless of what you load (see what happens when you remove each of them sequentially starting from the last one)?

lramach commented 11 years ago

The JVM seems to be getting created now, but I am facing a problem with the stanford-core-nlp gem. When I run the following line on the console I get the below error.

I am not sure what is wrong since the file mentioned in the highlighted line englishPCFG.ser.gz is in the appropriate folder. Any suggestions would be of great help! Thanks!

> pipeline = StanfordCoreNLP.load(:tokenize, :ssplit, :pos, :lemma, :parse, :ner, :dcoref) Adding annotator tokenize Adding annotator ssplit Adding annotator pos Loading default properties from tagger /local/rails/expertiza/releases/20130103025217/vendor/cache/ruby/1.8/gems/stanford-core-nlp-0.3.0/lib/../bin/taggers/english-left3words-distsim.tagger Reading POS tagger model from /local/rails/expertiza/releases/20130103025217/vendor/cache/ruby/1.8/gems/stanford-core-nlp-0.3.0/lib/../bin/taggers/english-left3words-distsim.tagger ... done [1.0 sec]. Adding annotator lemma Adding annotator parse Loading parser from serialized file edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz ... java.io.IOException: Unable to resolve "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz" as either class path, filename or URL at edu.stanford.nlp.io.IOUtils.getInputStreamFromURLOrClasspathOrFileSystem(IOUtils.java:408) at edu.stanford.nlp.io.IOUtils.readStreamFromString(IOUtils.java:356) at edu.stanford.nlp.parser.lexparser.LexicalizedParser.getParserFromSerializedFile(LexicalizedParser.java:530) at edu.stanford.nlp.parser.lexparser.LexicalizedParser.getParserFromFile(LexicalizedParser.java:328) at edu.stanford.nlp.parser.lexparser.LexicalizedParser.loadModel(LexicalizedParser.java:148) at edu.stanford.nlp.parser.lexparser.LexicalizedParser.loadModel(LexicalizedParser.java:134) at edu.stanford.nlp.pipeline.ParserAnnotator.loadModel(ParserAnnotator.java:147) at edu.stanford.nlp.pipeline.ParserAnnotator.(ParserAnnotator.java:94) at edu.stanford.nlp.pipeline.StanfordCoreNLP$12.create(StanfordCoreNLP.java:777) at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:80) at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:301) at edu.stanford.nlp.pipeline.StanfordCoreNLP.(StanfordCoreNLP.java:145) at edu.stanford.nlp.pipeline.StanfordCoreNLP.(StanfordCoreNLP.java:141) Loading parser from text file edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz java.io.IOException: Unable to resolve "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz" as either class path, filename or URL at edu.stanford.nlp.io.IOUtils.getInputStreamFromURLOrClasspathOrFileSystem(IOUtils.java:408) at edu.stanford.nlp.io.IOUtils.readReaderFromString(IOUtils.java:427) at edu.stanford.nlp.parser.lexparser.LexicalizedParser.getParserFromTextFile(LexicalizedParser.java:464) at edu.stanford.nlp.parser.lexparser.LexicalizedParser.getParserFromFile(LexicalizedParser.java:330) at edu.stanford.nlp.parser.lexparser.LexicalizedParser.loadModel(LexicalizedParser.java:148) at edu.stanford.nlp.parser.lexparser.LexicalizedParser.loadModel(LexicalizedParser.java:134) at edu.stanford.nlp.pipeline.ParserAnnotator.loadModel(ParserAnnotator.java:147) at edu.stanford.nlp.pipeline.ParserAnnotator.(ParserAnnotator.java:94) at edu.stanford.nlp.pipeline.StanfordCoreNLP$12.create(StanfordCoreNLP.java:777) at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:80) at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:301) at edu.stanford.nlp.pipeline.StanfordCoreNLP.(StanfordCoreNLP.java:145) at edu.stanford.nlp.pipeline.StanfordCoreNLP.(StanfordCoreNLP.java:141) NullPointerException: unknown exception from /local/rails/expertiza/releases/20130103025217/vendor/cache/ruby/1.8/gems/stanford-core-nlp-0.3.0/lib/stanford-core-nlp.rb:124:in new' from /local/rails/expertiza/releases/20130103025217/vendor/cache/ruby/1.8/gems/stanford-core-nlp-0.3.0/lib/stanford-core-nlp.rb:124:inload' from (irb):7

louismullie commented 11 years ago

You're going to hate me for this, but ... Can you try with the latest gem version? I'm pretty sure your issue has been fixed in there.

swarzech commented 11 years ago

I am getting the JVM error as well. I just started working with the gem today. Do you have any insite to what the issue might be?

louismullie commented 11 years ago

Hi Stefanie,

What does the following output?

$DEBUG=true
require 'rjb'
Point = Rjb::import('java.awt.Point')
p = Point.new(0, 0)
p.y = 80
puts "x=#{p.x}, y=#{p.y}" # => "0,80"
lramach commented 11 years ago

Hi Louis, I dont think I can upgrade to the latest version of the stanford NLP gem, since my app runs Ruby 1.8.7, with which the latest gem version may not be compatible!

Would you happen to have any other suggestions for fixing the above error "Unable to resolve "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz"? Could this have something to do with the fact that the grammar file is gzipped? It works fine on my development system, on which I have the gzipped format.

Thanks!

louismullie commented 11 years ago

Hey LRamach,

If you're motivated you could go and find the commit that fixes the bug, but I'm not even sure which one that is. A lot has changed since 0.3.0! I would suggest you upgrade to the latest version; I'm pretty sure that there are no Ruby-compatibility-breaking changes in there.

lramach commented 11 years ago

Thanks! I will try that out!

zkt commented 11 years ago

I'm having trouble with Ruby 1.9.3? rjb? jvm? treat? on Mac OS X 10.6. It might be my own fault because I'm using rvm to manage Ruby installations I'm also trying to use the gem with Rails which has brought its own problems. ie the requires in treat e.g. 'engtagger' need to be added to the rails app's Gemfile. This is what I was doing when I came across this rjb-jvm bug. I'd just added gem "stanford-core-nlp" to the app's Gemfile and the app broke in the console :(

I tried to install treat with Ruby 1.8.7 but the data Hashes failed to load, I hacked the data files so they were old style Hashes, but then what should have ended up being worker Classes (I think) ended up being Structs :/ something to do with 1.8.7 not having 'define_singleton_method' (I think)

Here's what Point = Rjb::import('java.awt.Point') [mentioned above] produces in irb i.e. not in the RoR app rails console 1.9.3p327 :002 > require 'rjb' => true 1.9.3p327 :003 > $DEBUG=true => true 1.9.3p327 :004 > Point = Rjb::import('java.awt.Point') Invalid memory access of location 0x0 rip=0x1035f9f20

(irb):4: [BUG] Segmentation fault ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin10.8.0]

Control frame information ----------------------------------------------- c:0024 p:---- s:0086 b:0086 l:000085 d:000085 CFUNC :import c:0023 p:0017 s:0082 b:0082 l:000688 d:000081 EVAL (irb):4 c:0022 p:---- s:0080 b:0080 l:000079 d:000079 FINISH c:0021 p:---- s:0078 b:0078 l:000077 d:000077 CFUNC :eval c:0020 p:0028 s:0071 b:0071 l:000070 d:000070 METHOD /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/workspace.rb:80 c:0019 p:0033 s:0064 b:0063 l:000062 d:000062 METHOD /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/context.rb:254 c:0018 p:0031 s:0058 b:0058 l:0008c8 d:000057 BLOCK /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb.rb:159 c:0017 p:0042 s:0050 b:0050 l:000049 d:000049 METHOD /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb.rb:273 c:0016 p:0011 s:0045 b:0045 l:0008c8 d:000044 BLOCK /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb.rb:156 c:0015 p:0144 s:0041 b:0041 l:000024 d:000040 BLOCK /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/ruby-lex.rb:243 c:0014 p:---- s:0038 b:0038 l:000037 d:000037 FINISH c:0013 p:---- s:0036 b:0036 l:000035 d:000035 CFUNC :loop c:0012 p:0009 s:0033 b:0033 l:000024 d:000032 BLOCK /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/ruby-lex.rb:229 c:0011 p:---- s:0031 b:0031 l:000030 d:000030 FINISH c:0010 p:---- s:0029 b:0029 l:000028 d:000028 CFUNC :catch c:0009 p:0023 s:0025 b:0025 l:000024 d:000024 METHOD /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/ruby-lex.rb:228 c:0008 p:0046 s:0022 b:0022 l:0008c8 d:0008c8 METHOD /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb.rb:155 c:0007 p:0011 s:0019 b:0019 l:001c38 d:000018 BLOCK /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb.rb:70 c:0006 p:---- s:0017 b:0017 l:000016 d:000016 FINISH c:0005 p:---- s:0015 b:0015 l:000014 d:000014 CFUNC :catch c:0004 p:0183 s:0011 b:0011 l:001c38 d:001c38 METHOD /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb.rb:69 c:0003 p:0142 s:0006 b:0006 l:000208 d:001088 EVAL /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/bin/irb:16 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH c:0001 p:0000 s:0002 b:0002 l:000208 d:000208 TOP

-- Ruby level backtrace information ---------------------------------------- /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/bin/irb:16:in <main>' /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb.rb:69:instart' /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb.rb:69:in catch' /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb.rb:70:inblock in start' /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb.rb:155:in eval_input' /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/ruby-lex.rb:228:ineach_top_level_statement' /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in catch' /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/ruby-lex.rb:229:inblock in each_top_level_statement' /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in loop' /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/ruby-lex.rb:243:inblock (2 levels) in each_top_level_statement' /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb.rb:156:in block in eval_input' /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb.rb:273:insignal_status' /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb.rb:159:in block (2 levels) in eval_input' /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/context.rb:254:inevaluate' /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/workspace.rb:80:in evaluate' /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/workspace.rb:80:ineval' (irb):4:in irb_binding' (irb):4:inimport'

-- C level backtrace information -------------------------------------------

See Crash Report log file under ~/Library/Logs/CrashReporter or /Library/Logs/CrashReporter, for the more detail of.

-- Other runtime information -----------------------------------------------

[NOTE] You may have encountered a bug in the Ruby interpreter or extension libraries. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html

BTW my use of the treat gem could be viewed as trivial as all I'm after is splitting text into sentences and phrases ready for translation, which could be done with regex ,with the odd tolerable error, so treat is probably overkill for what I want.

Thanks for your work :)

louismullie commented 11 years ago

Hey,

I believe this is an issue with Rjb 1.4.5. The fix is to:

gem uninstall rjb
gem install rjb -v 1.4.3

See #17. Please report if it works!

zkt commented 11 years ago

Have done as suggested and also added "gem 'rjb', "1.4.3" to the app's Gemfile and then did bundle update

Ok rjb 1.4.3 seems to load and function in the RoR console :), but ... here's what I get creating the awt point

1.9.3-p327 :009 > Point = Rjb::import('java.awt.Point') => #Rjb::Java_awt_Point:0x00000100f27578 1.9.3-p327 :010 > p = Point.new(0, 0) Exception NoMethodError' at /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/proxies/proxy.rb:16 - undefined methodto_hash' for "":String => java.awt.Point[x=0,y=0] 1.9.3-p327 :011 > p.y = 80 Exception NoMethodError' at /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/proxies/proxy.rb:16 - undefined methodto_hash' for "":String => 80 1.9.3-p327 :012 > puts "x=#{p.x}, y=#{p.y}" # => "0,80" Exception NoMethodError' at /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/proxies/proxy.rb:16 - undefined methodto_hash' for "":String Exception NoMethodError' at /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/proxies/proxy.rb:16 - undefined methodto_hash' for "":String x=0, y=80 => nil

So the point is there, but for some reason treat produces a 'NoMethodError' exception.

In irb I get this

1.9.3-p327 :001 > $DEBUG=true => true 1.9.3-p327 :002 > require 'rjb' Exception `LoadError' at /Users/zkt/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36 - cannot load such file -- rjb => true 1.9.3-p327 :003 > Point = Rjb::import('java.awt.Point') => #Rjb::Java_awt_Point:0x00000100b3d4a8 1.9.3-p327 :004 > p = Point.new(0, 0) => #Rjb::Rjb_JavaProxy:0x00000100b310e0 1.9.3-p327 :005 > p.y = 80 => 80 1.9.3-p327 :006 > puts "x=#{p.x}, y=#{p.y}" # => "0,80" x=0, y=80 => nil 1.9.3-p327 :007 >

Another Exception but Hey it works. I'll see what happens when I run the app from Webrick, if there's any trouble I'll let you know.

Thanks again :)

louismullie commented 11 years ago

Weird - this is probably due to a Treat DSL/Rjb conflict. You shouldn't have any problems when actually using Treat, though. I'll look into this soon.

zkt commented 11 years ago

I'm not sure if this is the right place for this but, .... After bundle update I ran the treat installer for treat 2.0.4 A few gems failed to install because of dependency issues.

Installer Output for failed gems

  1. Installing core dependencies.

Warning: couldn't install gem 'bson_ext' (bson_ext requires bson (~> 1.8.2)). Installing mongo... Warning: couldn't install gem 'mongo' (mongo requires bson (~> 1.8.2)). Installing lda-ruby... Warning: couldn't install gem 'lda-ruby' (mocha requires metaclass (~> 0.0.1)). Installing stanford-core-nlp... Installing linguistics... This library also presents tie-ins for the 'linkparser' and 'wordnet' libraries, which you can enable by installing the gems of the same name. Installing ruby-readability... Warning: couldn't install gem 'ruby-readability' (ruby-readability requires guess_html_encoding (>= 0.0.4)) Warning: couldn't install gem 'narray' (ERROR: Failed to build gem native extension. Warning: couldn't install gem 'fuzzy-string-match' (RubyInline requires ZenTest (~> 4.3)). Installing levenshtein-ffi... Fetching: ffi-1.1.5.gem (100%) Building native extensions. This could take a while... Fetching: levenshtein-ffi-1.0.3.gem (100%) Warning: couldn't install gem 'levenshtein-ffi' (levenshtein-ffi requires ffi (~> 1.1.5)).

  1. Installing dependencies for the English language Warning: couldn't install gem 'srx-english' (srx-english requires term-ansicolor (~> 1.0.5)).

Everything else installed OK

I've installed the gems manually and all went well except for linkparser which gave this error

checking for pkg-config... yes Package link-grammar was not found in the pkg-config search path. Perhaps you should add the directory containing `link-grammar.pc' to the PKG_CONFIG_PATH environment variable No package 'link-grammar' found

So a missing package or an unset environment variable. I'm not sure if the gem install failures are an rvm issue

treat is functioning (at least for my basic needs) except when I call :parse or .parse I get this error in the rails app console

.9.3-p327 :001 > include Treat::Core::DSL => Object 1.9.3-p327 :002 > ic=IndexController.new # Instantiate the controller class 1.9.3-p327 :003 > ws=ic.index # which returns an array of strings by doing para.apply :chunk, :segment 1.9.3-p327 :004 > s1=sentence(ws[0]) #grab the first string into a treat sentence => Sentence (2172107740) --- "The Independent Media [...] issues." --- {} --- []
then either 1.9.3-p327 :005 > s1.parse or 1.9.3-p327 :006 > s1.apply :parse produce the error

1.9.3-p327 :005 > s1.parse NoMethodError: undefined method children' for nil:NilClass from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/core/dsl.rb:17:inmethod_missing' from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/workers/processors/parsers/stanford.rb:57:in recurse' from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/workers/processors/parsers/stanford.rb:50:inparse' from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/entities/entity/delegatable.rb:66:in call_worker' from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/treat-2.0.4/lib/treat/entities/entity/delegatable.rb:40:inblock (2 levels) in add_workers' from (irb):5 from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in start' from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.11/lib/rails/commands/console.rb:8:instart' from /Users/zkt/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.11/lib/rails/commands.rb:41:in <top (required)>' from script/rails:6:inrequire' from script/rails:6:in `

'

Just thought I'd let you know :-) It'd be nice to get phrases from the sentences, but hey....

Cheers

louismullie commented 11 years ago

I need to fix this and put a better error message, but I think this is just because you did not tokenize the sentence before parsing it. s.apply :tokenize, :parse should work.

zkt commented 11 years ago

Hmmn that seems kinda counter intuitive, from the manual ....

Parsers

Parsers parse a group of words (a sentence, phrase or fragment) into its syntactical tree.

s = sentence('The prospect of an Asian arms race is genuinely frightening.').parse

...

and

Tokenizers

Tokenizers split a group of words (a sentence, phrase or fragment) into tokens.

s = sentence('An uninteresting sentence, yes it is.').tokenize

...

So reading that I thought tokens would be too fine grained for what I want and I thought the output from a Parser would contain the tokens anyway. Does it depend on the Parser?

I'll try what you suggest

BTW there's a typo I've noticed in the manual under "Word stemming" it says "Available annotators" instead of "Available Stemmers"

Cheers

louismullie commented 11 years ago

Thanks for the typo. The manual is outdated, you need to tokenize before parsing. All parsers perform tokenizing as a first step, so it's logical to separate that from the parsing process. There was a limitation that I hadn't managed to get around initially with the Stanford parser, but it's now been fixed.

zkt commented 11 years ago

Please pardon my NLP ignorance :) s.apply :tokenize, :parse works!. Thanks

PS the rails webrick server can't cope with the java VM used by the stanford gem, I've switched to another server https://github.com/37signals/pow. Thanks again Louis

arbox commented 7 years ago

Please be patient, we are working on this issue!