I am having problems with a php script that says that it cannot find file /root/nltk_data/tokenizers/punkt/english.pickle . However I confirmed that the file is here. II downloaded the whole data set multiple times)
The php script actually runs a python script and the nltk (a python module) says that it cannot find /root/nltk_data/tokenizers/punkt/english.pickle
$dir = dirname(__FILE__);
$command = "/usr/bin/python ". $dir . "/test.py";
exec($command, $output);
On the other hands when i run the python script from command line it works perfectly fine and is able to access the file.
python test.py
Is it possible to enable php to see those files? I chmod 777 the file but this didn't help.
the script contains:
#!/usr/bin/env/ python
import nltk
try:
tokens = nltk.word_tokenize("I like apples.")
tagged = nltk.pos_tag(tokens)
print "OK!"
#print ' * '.join(tokens)
except Exception:
print "error!"
pass
Error log:
Traceback (most recent call last):
File "/var/zpanel/hostdata/zadmin/public_html/my_domain_com/test.py", line 39, in <module>
tagged = nltk.pos_tag(tokens)
File "/usr/local/lib/python2.7/site-packages/nltk-2.0.4-py2.7.egg/nltk/tag/__init__.py", line 99, in pos_tag
tagger = load(_POS_TAGGER)
File "/usr/local/lib/python2.7/site-packages/nltk-2.0.4-py2.7.egg/nltk/data.py", line 605, in load
resource_val = pickle.load(_open(resource_url))
File "/usr/local/lib/python2.7/site-packages/nltk-2.0.4-py2.7.egg/nltk/data.py", line 686, in _open
return find(path).open()
File "/usr/local/lib/python2.7/site-packages/nltk-2.0.4-py2.7.egg/nltk/data.py", line 467, in find
raise LookupError(resource_not_found)
LookupError:
Resource taggers/maxent_treebank_pos_tagger/english.pickle not found. Please use the NLTK Downloader to obtain the resource:
>>> nltk.download()
Searched in:
- '/root/nltk_data'
- '/usr/share/nltk_data'
- '/usr/local/share/nltk_data'
- '/usr/lib/nltk_data'
- '/usr/local/lib/nltk_data'