小编Die*_*dal的帖子

从PHP调用.jar文件 - Stanford NLP - 无法找到或加载主java类

我有一个项目正在使用这个包agentile/PHP-Stanford-NLP(PHP接口到斯坦福NLP工具(POS Tagger,NER,Parser)调用几个.jar文件.一切都在localhost(MAMP)上工作正常但是当我将它部署到laravel forge时它不再工作了.我在服务器中安装了JRE/JDK,Oracle JDK,Oracle JDK 8.

这是我用来调用java文件的代码段:

$parser = new \StanfordNLP\Parser(
        public_path().'/stanford-parser.jar',
        public_path().'/stanford-parser-3.4.1-models.jar'
);
$parser = $parser->parseSentence($text);
Run Code Online (Sandbox Code Playgroud)

这是错误来自的代码段:

$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()));
Run Code Online (Sandbox Code Playgroud)

https://github.com/agentile/PHP-Stanford-NLP/blob/51f99f1aaa1c3d5822fe634346b2b4b33a7a6223/src/StanfordNLP/Parser.php#L90

这是错误:

Error: Could not …
Run Code Online (Sandbox Code Playgroud)

php java classpath stanford-nlp laravel

11
推荐指数
1
解决办法
618
查看次数

标签 统计

classpath ×1

java ×1

laravel ×1

php ×1

stanford-nlp ×1