为什么删除初始化程序不会改变行为?

时间:2015-08-02 14:22:07

标签: java ruby sinatra rack stanford-nlp

在我的Sinatra应用程序中,我正在使用宝石'sinatra-initializers','sinatra / asset_pipeline','sinatra / assetpack'等等,我有一个初始化程序,可以加载自然语言处理库:

#00_initializer.rb
    StanfordCoreNLP.jar_path = '/path/to/stanford-core-folder/'
    StanfordCoreNLP.model_path = '/path/to/stanford-core-folder/'
    NLPPipeline = StanfordCoreNLP.load(:tokenize, :ssplit, :pos, :lemma, :parse)

#nlp.rb
    def get_tokens(word)
        text = StanfordCoreNLP::Annotation.new(word)
        NLPPipeline.annotate(text)
        text.get(:tokens).each {|token| p token.get(:value).to_s} 
    end

当我启动服务器时,一切正常:

  >> $ rackup
Adding annotator tokenize
Adding annotator ssplit
Adding annotator pos
Loading default properties from tagger /Users/JW/Dropbox/Dev/Websites/FrontEnd/_JS plugins/stanford-core-nlp-minimal/taggers/english-left3words-distsim.tagger
Reading POS tagger model from /Users/JW/Dropbox/Dev/Websites/FrontEnd/_JS plugins/stanford-core-nlp-minimal/taggers/english-left3words-distsim.tagger ... done [1.5 sec].
Adding annotator lemma
Adding annotator parse
Loading parser from serialized file /Users/JW/Dropbox/Dev/Websites/FrontEnd/_JS plugins/stanford-core-nlp-minimal/grammar/englishPCFG.ser.gz ... done [1.5 sec].
Notice: for 10x faster LSI support, please install http://rb-gsl.rubyforge.org/
[2015-08-02 19:30:57] INFO  WEBrick 1.3.1
[2015-08-02 19:30:57] INFO  ruby 2.0.0 (2013-11-22) [x86_64-darwin12.5.0]
[2015-08-02 19:30:57] INFO  WEBrick::HTTPServer#start: pid=26229 port=9292

但是一旦我调用该函数,我就会得到一个

RuntimeError at /
java.lang.NullPointerException 

直到昨天,一切都很好,据我所知,我没有改变任何东西。试图挖掘周围的问题,我从初始化程序中注释掉了所有内容。但是,初始化程序加载与以前完全相同:

>> $ rackup
    Adding annotator tokenize
    Adding annotator ssplit
    Adding annotator pos
    Loading default properties from tagger /Users/JW/Dropbox/Dev/Websites/FrontEnd/_JS plugins/stanford-core-nlp-minimal/taggers/english-left3words-distsim.tagger
    ...[etc]
    [2015-08-02 19:30:57] INFO  WEBrick 1.3.1
    [2015-08-02 19:30:57] INFO  ruby 2.0.0 (2013-11-22) [x86_64-darwin12.5.0]
    [2015-08-02 19:30:57] INFO  WEBrick::HTTPServer#start: pid=26229 port=9292

所以...我的问题:幻影初始化器的处理是什么?而且,我突然行为不端的Java库可能是什么原因?

0 个答案:

没有答案