I’m unable to get a simple ruby script to work that makes use of a Java
class and could use some assistance. I’ve read all through the wiki and
tried some googling, but no luck.
JRuby Version:
jruby 1.7.0 (1.9.3p203) 2012-10-22 ff1ebbe on Java HotSpot™ 64-Bit
Server VM 1.7.0_09-b05 [darwin-x86_64]
Java Version:
java version “1.7.0_09”
Java™ SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot™ 64-Bit Server VM (build 23.5-b02, mixed mode)
I’m trying to create a super simple ruby script that interfaces with the
Stanford NLP Parser (Java). For now I’m just trying to recreate, in
Ruby, a the first line from their Java demo. I’ve run the demo and it
runs fine. Here is a snippet of the Java code:
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.io.StringReader;
import edu.stanford.nlp.objectbank.TokenizerFactory;
import edu.stanford.nlp.process.CoreLabelTokenFactory;
import edu.stanford.nlp.process.DocumentPreprocessor;
import edu.stanford.nlp.process.PTBTokenizer;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.ling.HasWord;
import edu.stanford.nlp.ling.Sentence;
import edu.stanford.nlp.trees.*;
import edu.stanford.nlp.parser.lexparser.LexicalizedParser;
class ParserDemo {
public static void main(String[] args) {
LexicalizedParser lp =
LexicalizedParser.loadModel(“edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz”);
…
Here is my simple jruby script:
require ‘./stanford-parser.jar’
require ‘./stanford-parser-models.jar’
java_import “edu.stanford.nlp.parser.lexparser.LexicalizedParser”
lp =
LexicalizedParser.loadModel(“edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz”)
puts “Done”
I get this error. Any help is appreciated.
CallableSelector.java:112:in findMatchingCallableForArgs': java.lang.ArrayIndexOutOfBoundsException: 2 from CallableSelector.java:45:in
matchingCallableArityN’
from RubyToJavaInvoker.java:215:in findCallable' from StaticMethodInvoker.java:28:in
call’
from StaticMethodInvoker.java:55:in call' from CachingCallSite.java:326:in
cacheAndCall’
from CachingCallSite.java:170:in call' from blah.rb:6:in
file’
from blah.rb:-1:in load' from Ruby.java:770:in
runScript’
from Ruby.java:763:in runScript' from Ruby.java:640:in
runNormally’
from Ruby.java:489:in runFromMain' from Main.java:375:in
doRunFromMain’
from Main.java:264:in internalRun' from Main.java:230:in
run’
from Main.java:214:in run' from Main.java:194:in
main’
Thanks!