这是python代码:
from nltk.tag import StanfordNERTagger
st = StanfordNERTagger('D:/stanford-ner-2018-02-27/classifiers/english.all.3class.distsim.crf.ser.gz',
'D:/stanford-ner-2018-02-27/stanford-ner.jar')
r=st.tag('Rami Eid is studying at Stony Brook University in NY'.split())
print(r)
我所有的绝对路径都是正确的。我也设置了JAVA_HOME环境变量。但我正面临着这些错误。
C:\Users\Yunus\AppData\Local\Programs\Python\Python36\python.exe E:/WorkStation/untitled1/a.py
C:\Users\Yunus\AppData\Local\Programs\Python\Python36\lib\site-packages\nltk\tag\stanford.py:183: DeprecationWarning:
The StanfordTokenizer will be deprecated in version 3.2.5.
Please use nltk.tag.corenlp.CoreNLPPOSTagger or nltk.tag.corenlp.CoreNLPNERTagger instead.
super(StanfordNERTagger, self).__init__(*args, **kwargs)
Traceback (most recent call last):
File "E:/WorkStation/untitled1/a.py", line 6, in <module>
r=st.tag('Rami Eid is studying at Stony Brook University in NY'.split())
File "C:\Users\Yunus\AppData\Local\Programs\Python\Python36\lib\site-packages\nltk\tag\stanford.py", line 84, in tag
return sum(self.tag_sents([tokens]), [])
File "C:\Users\Yunus\AppData\Local\Programs\Python\Python36\lib\site-packages\nltk\tag\stanford.py", line 89, in tag_sents
config_java(options=self.java_options, verbose=False)
File "C:\Users\Yunus\AppData\Local\Programs\Python\Python36\lib\site-packages\nltk\internals.py", line 58, in config_java
_java_bin = find_binary('java', bin, env_vars=['JAVAHOME', 'JAVA_HOME'], verbose=verbose, binary_names=['java.exe'])
File "C:\Users\Yunus\AppData\Local\Programs\Python\Python36\lib\site-packages\nltk\internals.py", line 604, in find_binary
binary_names, url, verbose))
File "C:\Users\Yunus\AppData\Local\Programs\Python\Python36\lib\site-packages\nltk\internals.py", line 598, in find_binary_iter
url, verbose):
File "C:\Users\Yunus\AppData\Local\Programs\Python\Python36\lib\site-packages\nltk\internals.py", line 569, in find_file_iter
raise LookupError('\n\n%s\n%s\n%s' % (div, msg, div))
LookupError:
===========================================================================
NLTK was unable to find the java file!
Use software specific configuration paramaters or set the JAVAHOME environment variable.
===========================================================================
Process finished with exit code 1
请有人找到我的解决方案吗?
python 3.6.2(64位版本) jdk 1.8.0_61