Reputation: 91
when i use this command
java -mx100m edu.stanford.nlp.trees.EnglishGrammaticalStructure -sentFile input.txt -collapsedTree -CCprocessed -parseTree -parserFile englishPCFG.ser.gz it return this Error: unable to find or load main class edu.stanford.nlp.trees.EnglishGrammaticalStructure
and when i use this command
java -cp "*" edu.stanford.nlp.trees.EnglishGrammaticalStructure -sentFile input.txt -collapsedTree -CCprocessed -parseTree -parserFile englishPCFG.ser.gz it retruns
Loading parser from serialized file englishPCFG.ser.gz ...
java.io.IOException: Unable to resolve "englishPCFG.ser.gz" as either class path, filename or URL
at edu.stanford.nlp.io.IOUtils.getInputStreamFromURLOrClasspathOrFileSystem(IOUtils.java:463)
at edu.stanford.nlp.io.IOUtils.readStreamFromString(IOUtils.java:396)
at edu.stanford.nlp.parser.lexparser.LexicalizedParser.getParserFromSerializedFile(LexicalizedParser.java:599)
at edu.stanford.nlp.parser.lexparser.LexicalizedParser.getParserFromFile(LexicalizedParser.java:394)
at edu.stanford.nlp.parser.lexparser.LexicalizedParser.loadModel(LexicalizedParser.java:181)
at edu.stanford.nlp.parser.lexparser.LexicalizedParser.loadModel(LexicalizedParser.java:160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at edu.stanford.nlp.trees.GrammaticalStructure.loadParser(GrammaticalStructure.java:1394)
at edu.stanford.nlp.trees.GrammaticalStructure.main(GrammaticalStructure.java:1645)
Loading parser from text file englishPCFG.ser.gz java.io.IOException: Unable to resolve "englishPCFG.ser.gz" as either class path, filename or URL
at edu.stanford.nlp.io.IOUtils.getInputStreamFromURLOrClasspathOrFileSystem(IOUtils.java:463)
at edu.stanford.nlp.io.IOUtils.readerFromString(IOUtils.java:591)
at edu.stanford.nlp.parser.lexparser.LexicalizedParser.getParserFromTextFile(LexicalizedParser.java:533)
at edu.stanford.nlp.parser.lexparser.LexicalizedParser.getParserFromFile(LexicalizedParser.java:396)
at edu.stanford.nlp.parser.lexparser.LexicalizedParser.loadModel(LexicalizedParser.java:181)
at edu.stanford.nlp.parser.lexparser.LexicalizedParser.loadModel(LexicalizedParser.java:160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at edu.stanford.nlp.trees.GrammaticalStructure.loadParser(GrammaticalStructure.java:1394)
at edu.stanford.nlp.trees.GrammaticalStructure.main(GrammaticalStructure.java:1645)
Exception in thread "main" java.lang.RuntimeException: java.lang.NullPointerException
at edu.stanford.nlp.trees.GrammaticalStructure.main(GrammaticalStructure.java:1655)
Caused by: java.lang.NullPointerException
at edu.stanford.nlp.trees.GrammaticalStructure.main(GrammaticalStructure.java:1652)
i don't know where is the problem and how to use this library
Upvotes: 0
Views: 103
Reputation: 8739
You have to supply the resource's full path in the command.
edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz
When Java tries to find something, it looks for that path in all of the jar files in the CLASSPATH. Also the -cp "*"
will only work if you are executing the command in the directory with all of the .jar
files.
Upvotes: 1