Open gupul2k opened 9 years ago
Solved. After upgrading JDK to build 1.8.0_25.
I updated to 1.8.0_31 but
<?php
require(THIRD_PARTIES_DIRECTORY . "autoload.php");
echo "POS\n";
$pos = new StanfordNLP\POSTagger(
'./stanford-postagger-full-2015-01-30/models/english-left3words-distsim.tagger',
'./stanford-postagger-full-2015-01-30/stanford-postagger.jar'
);
$result = $pos->tag(explode(' ', "What does the fox say?"));
print_r($result);
?>
outputs
POS
Array
(
)
Solved with absolute path instead of relative path
<?php
require(THIRD_PARTIES_DIRECTORY . "autoload.php");
echo "POS\n";
$pos = new \StanfordNLP\POSTagger(
__DIR__ . '/stanford-postagger-full-2015-01-30/models/english-left3words-distsim.tagger',
__DIR__ . '/stanford-postagger-full-2015-01-30/stanford-postagger.jar'
);
$result = $pos->tag(explode(' ', "What does the fox say?"));
print_r($result);
?>
Does any one have a working setup of this POS tagger? I just can not get it set up properly for windows
facing same problems. have latest java version, all paths are correct and not working on a windows.
Same issues too on Mac OS X.
array(0) { } is my output what is (THIRD_PARTIES_DIRECTORY in the code please explain
not working when i add DIR. to the path
I've got the same issues, i always get array(0) { } but no other errors are thrown.
Any solutions?
I have the exact same code but I also get
array (size=0) empty
Anyone solved it yet?
@Wmichaelsen
I had same issue. I took prev. version (stanford-ner 3.5.2 2015-04-20) and it is working.
@NameIvan where can I find the previous versions?
@Wmichaelsen Here http://nlp.stanford.edu/software/CRF-NER.shtml At the bottom of the page
@NameIvan Oh sorry obviously i find them on stanford's site... Tried but unfortunately it didn't help, thanks anyways!
@Wmichaelsen I have it is working on Linux (java version "1.8.0_45"). Do you work on the other OS?
Im on OSX, but I actually work with the POS tagger, not the NER, so perhaps that's the problem
@NameIvan
There is an issue with a invalid java classpath if you use readme example. Adding a slf4j-api.jar to the second POSTagger constructor argument does work for me:
new POSTagger(
$absolutePostaggerPath . '/models/english-left3words-distsim.tagger',
$absolutePostaggerPath . '/stanford-postagger.jar:'. $absolutePostaggerPath . '/lib/slf4j-api.jar'
);
I found a solution for an empty array. If you have this issue try to change line 91 of StanfordTagger.php from:
return isset($results[0]) ? $results[0] : array();
to:
return isset($results[0]) ? $results : array();
Mnosek : i trying this way but still not work .
Finally working for me;
Added the following code to test.php
<?php error_reporting('E_ALL');
require_once 'autoload.php';
$pos = new \StanfordNLP\POSTagger(
DIR.'\stanford-postagger-full-2014-08-27\models\english-left3words-distsim.tagger',
DIR.'\stanford-postagger-full-2014-08-27\stanford-postagger.jar'
);
$result = $pos->tag(explode(' ', "What does the fox say?"));
var_dump($result);
?>
Download the 'Full' zip from here; http://nlp.stanford.edu/software/tagger.shtml#History 3.4.1 2014-08-27 Add Spanish model English / Full <<<<
Place the unzipped 'stanford-postagger-full-2014-08-27' folder in the same folder as the php code(above).
Output:
array(6) { [0]=> array(2) { [0]=> string(4) "What" [1]=> string(2) "WP" } [1]=> array(2) { [0]=> string(4) "does" [1]=> string(3) "VBZ" } [2]=> array(2) { [0]=> string(3) "the" [1]=> string(2) "DT" } [3]=> array(2) { [0]=> string(3) "fox" [1]=> string(2) "NN" } [4]=> array(2) { [0]=> string(3) "say" [1]=> string(2) "VB" } [5]=> array(2) { [0]=> string(1) "?" [1]=> string(1) "." } }
yes it's work for php but it not possible in laravel??
Does anyone have a solution for this yet?
Here is the code and coming empty array.
<?php
require './PHP-Stanford-NLP-master/src/StanfordNLP/Base.php'; require './PHP-Stanford-NLP-master/src/StanfordNLP/Exception.php'; require './PHP-Stanford-NLP-master/src/StanfordNLP/Parser.php'; require './PHP-Stanford-NLP-master/src/StanfordNLP/StanfordTagger.php'; require './PHP-Stanford-NLP-master/src/StanfordNLP/NERTagger.php';
$pos = new \StanfordNLP\NERTagger('/Users/xxxx/Downloads/stanford-ner-2014-10-26/classifiers/english.all.3class.distsim.crf.ser.gz','/Users/xxxx/Downloads/stanford-ner-2014-10-26/stanford-ner.jar'); $result = $pos->tag(explode(' ', "The Federal Reserve Bank of New York led by Timothy R. Geithner.")); var_dump($result);
?>
O/P
array(0) { }