louismullie / stanford-core-nlp

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

RuntimeError: Could not find JAR file (looking in ~/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/stanford-core-nlp-0.5.3/bin/joda-time.jar). #52

Closed psychoslave closed 6 years ago

psychoslave commented 6 years ago

Hi,

I'm trying to run this gemfile on Fedora 27. The installation process was:

gem install stanford-core-nlp
wget http://nlp.stanford.edu/software/stanford-postagger-full-2014-10-26.zip
unzip stanford-postagger-full-2014-10-26.zip
mv stanford-postagger-full-2014-10-26/* ~/.rbenv/versions/$(rbenv version|cut -d\  -f1)/lib/ruby/gems/*/gems/stanford-core-nlp-*/bin
rmdir stanford-postagger-full-2014-10-26
rm stanford-postagger-full-2014-10-26.zip
ls ~/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/stanford-core-nlp-0.5.3/bin
AnnotationBridge.java  README.txt                            stanford-postagger-3.5.0-sources.jar  stanford-postagger.jar
build.xml              sample-input.txt                      stanford-postagger.bat                stanford-postagger.sh
data                   sample-output.txt                     stanford-postagger-full-2014-10-26    TaggerDemo2.java
LICENSE.txt            stanford-postagger-3.5.0.jar          stanford-postagger-gui.bat            TaggerDemo.java
models                 stanford-postagger-3.5.0-javadoc.jar  stanford-postagger-gui.sh             taggers

And trying a basic test will fail:

require 'stanford-core-nlp'
StanfordCoreNLP.use :french
text = %q{Socrate (en grec ancien Σωκράτης / Sōkrátēs) est un philosophe grec du Ve siècle av. J.-C. (né vers -470/469, mort en -399). Il est connu comme l’un des créateurs de la philosophie morale. Socrate n’a laissé aucun écrit, mais sa pensée et sa réputation se sont transmises par des témoignages indirects. Ses disciples Platon et Xénophon ont notablement œuvré à maintenir l'image de leur maître, qui est mis en scène dans leurs œuvres respectives. Les philosophes Démétrios de Phalère, et Maxime de Tyr dans sa Neuvième Dissertation1 ont écrit que Socrate est mort à l’âge de 70 ans.}
pipeline =  StanfordCoreNLP.load(:tokenize, :ssplit, :pos, :lemma, :parse, :ner, :dcoref)
RuntimeError: Could not find JAR file (looking in /home/psychoslave/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/stanford-core-nlp-0.5.3/bin/joda-time.jar).
from /home/psychoslave/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/bind-it-0.2.7/lib/bind-it/jar_loader.rb:20:in `load'

What did I missed in the installation process?

psychoslave commented 6 years ago

I simply had to configure the jar path:

StanfordCoreNLP.jar_path = "/usr/share/java/"
psychoslave commented 6 years ago

Note that with the previous installation specification, I had to do a bit more configuration:

cd ~/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/stanford-core-nlp-0.5.3/bin/models
ln -s . taggers # ’taggers/’ is suffixed to StanfordCoreNLP.model_path when looking for taggers files
ln -s $(locate frenchFactored.ser.gz  | head -n1 | xargs dirname) grammar # for frenchFactored.ser.gz

And within the ruby session:

# the following assume the file database is up to date, run `sudo updatedb` if needed
StanfordCoreNLP.jar_path = `locate xom.jar  | head -n1 | xargs dirname`.chomp.concat('/')
StanfordCoreNLP.model_path = `locate french.tagger | grep stanford-core-nlp | head -n1 | xargs dirname`.chomp.concat('/')

# hereStanfordCoreNLP.jar_path.empty? and StanfordCoreNLP.model_path.empty? should be checked