I've got a project that is using this package agentile/PHP-Stanford-NLP (PHP interface to Stanford NLP Tools (POS Tagger, NER, Parser) which calls a few .jar files. Everything is working ok on localhost (MAMP) but when I deployed it to laravel forge it is not working anymore. I installed JRE/JDK, Oracle JDK, Oracle JDK 8 in my server.
This is the piece of code I use to call the java files:
$parser = new \StanfordNLP\Parser(
public_path().'/stanford-parser.jar',
public_path().'/stanford-parser-3.4.1-models.jar'
);
$parser = $parser->parseSentence($text);
This is the piece of code where the error comes from:
$parser = $this->lexicalized_parser ? 'edu/stanford/nlp/models/lexparser/englishFactored.ser.gz' : 'edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz';
$osSeparator = $this->php_os == 'windows' ? ';' : ':';
$cmd = $this->getJavaPath()
. " $options -cp \""
. $this->getJar()
. $osSeparator
. $this->getModelsJar()
. '" edu.stanford.nlp.parser.lexparser.LexicalizedParser -encoding UTF-8 -outputFormat "'
. $this->getOutputFormat()
. "\" "
. $parser
. " "
. $tmpfname;
$process = proc_open($cmd, $descriptorspec, $pipes, dirname($this->getJar()));
This is the error:
Error: Could not find or load main class edu.stanford.nlp.parser.lexparser.LexicalizedParser
EDITED:
This is the $cmd
output from localhost:
java -mx300m -classpath */Applications/MAMP/htdocs/mydomainname/public/lib/slf4j-api.jar:/Applications/MAMP/htdocs/mydomainname/public/lib/slf4j-simple.jar:/Applications/MAMP/htdocs/mydomainname/public/stanford-parser.jar:/Applications/MAMP/htdocs/mydomainname/public/stanford-parser-3.4.1-models.jar edu.stanford.nlp.parser.lexparser.LexicalizedParser -encoding UTF-8 -outputFormat wordsAndTags,penn,typedDependencies edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz /private/tmp/phpnlpparserC7ptSf
This is the $cmd
output from production:
java -mx300m -classpath */home/forge/mydomainname.com/public/lib/slf4j-api.jar:/home/forge/mydomainname.com/public/lib/slf4j-simple.jar:/home/forge/mydomainname.com/public/stanford-parser.jar:/home/forge/mydomainname.com/public/stanford-parser-3.4.1-models.jar edu.stanford.nlp.parser.lexparser.LexicalizedParser -encoding UTF-8 -outputFormat wordsAndTags,penn,typedDependencies edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz /tmp/phpnlpparserRdsoE5