TheCodeSlinger / PHP-Class-Stanford-POS-Tagger

PHP Wrapper for Stanford's Part of Speech Java Tagger
MIT License
7 stars 9 forks source link

empty array #2

Open lijoabraham-zz opened 8 years ago

lijoabraham-zz commented 8 years ago

After doing all these ,I am still getting null result. Am I missing anything?

Code :- require('class_Stanford_POS_Tagger.php'); $pos = new Stanford_POS_Tagger('../PHP-Stanford-NLP-master/data/stanford-postagger-2015-12-09'); print_r($pos->array_tag("The cow jumped over the moon and the dish ran away with the spoon."));

slokuta commented 8 years ago

I'm having the same issue. Did you ever find a solution?

Thank you.

MinsungHong commented 8 years ago

Finally, I found a solution. My OS is windows 10. And I use the jar file of version 3.3.1 (released at 2014-01-04) from http://nlp.stanford.edu/software/tagger.shtml. (I tried new version, but it's not work. So i recommend version 3.3.1)

I just changed the line 71 from $tmp_path = '/tmp' to $tmp_path = './temp' in class_Stanford_POS_Tagger.php file. And then make a new folder in my work folder which contains test.php, class_Stanford_POS_Tagger.php, Stanford jar file and so on (i.e., i use same folder for all files). The new folder's name is temp. This new tem_path is relative path (i.e., it is path of my folder, not tmp folder of windows).

And it is working now :) My guess is that the problem related with permission of windows.

And then, my test source is following as: require('class_Stanford_POS_Tagger.php'); $pos = new Stanford_POS_Tagger(); var_dump($pos->array_tag("The cow jumped over the moon and."));

Thank you for Charles Hays.

MinsungHong commented 8 years ago

And If you want to use your php file in different folder of class_Stanford_POS_Tagger php file. You have to input this code $this->set_tmp_path($path); at __construct function in class_Stanford_POS_Tagger php file after setting the path.

And then, test source is following as: require('NLP_stanford/class_Stanford_POS_Tagger.php'); $pos = new Stanford_POS_Tagger(DIR.'/NLP_stanford'); var_dump($pos->array_tag("The cow jumped over the moon and."));

I hope it help for you.