2
我試圖從Stanford NLP Parser JRuby中實現Java類的集合實現自定義的Java類
我能夠實現常規的Java JRuby中,而不是斯坦福解析器類
#my requires/imports/includes, included multiple versions to be safe
require 'java'
include Java
require 'c:\\stanford-parser\\stanfordparser.jar'
require 'C:\\Stanford-Parser\\Current\\stanford-parser.jar'
require 'c:\\sun\\stanfordparser'
require 'rubygems'
include_class 'edu.stanford.nlp.parser.lexparser.LexicalizedParser'
#try to create an object of the java class i am importing, LexicalizedParser
lp = edu.stanford.nlp.parser.lexparser.LexicalizedParser
#the line above is what causes the error
#check if regular Java is working
list = java.util.ArrayList.new
a = "1"
b = "2"
list.add(a)
list.add(b)
d = list[0]
puts d # all of this works
我得到這個錯誤
~\rubyjavatest\lib\main.rb:15: undefined local variable or method `edu' for main:Object (NameError)
(中〜代表我切出的完整路徑,以縮短這個)
另外,如果我試試這個:
lp = java::edu::stanford::nlp.parser::lexparser::LexicalizedParser
我得到這個錯誤
~\rubyjavatest\lib\main.rb:15: cannot load Java class java.edu.stanford.nlp.parser.lexparser.LexicalizedParser (NameError)
任何幫助將是巨大的!
我假設你有這個工作。我從序列化文件/u/nlp/data/lexparser/englishPCFG.ser.gz獲得加載解析器...未找到文件:/u/nlp/data/lexparser/englishPCFG.ser.gz – irfn 2011-11-06 08:14:32