无法在 OS X 上实例化 StanfordNERTagger
Unable to instantiate StanfordNERTagger on OS X
我正在尝试实例化 StanfordNERTagger
。这就是我正在尝试的:
st = StanfordNERTagger("/Users/attitude/Desktop/english.all.3class.caseless.distsim.crf.ser.gz","/Users/attitude/Desktop/stanford-ner-2015-12-09/stanford-ner.jar")
我已将 CLASSPATH
变量设置为 /Users/attitude/Desktop/stanford-ner-2015-12-09/stanford-ner.jar
(我还尝试将父文件夹作为值 - /Users/attitude/Desktop/stanford-ner-2015-12-09
)。
但是,我收到此错误:
LookupError: Could not find stanford-ner.jar jar file at /Users/attitude/Desktop/stanford-ner-2015-12-09/stanford-ner.jar
.
我已经完成了这两个答案中提到的所有内容 - this and 。我现在还可以做什么来修复此错误?
OS X Yosemite - Python 2.7.
TL;DR:
不设置环境变量,使用关键字参数,model_filename
和path_to_jar
from nltk.tag import StanfordNERTagger
stanford_ner_dir = '/home/alvas/stanford-ner/'
eng_model_filename= stanford_ner_dir + 'classifiers/english.all.3class.distsim.crf.ser.gz'
my_path_to_jar= stanford_ner_dir + 'stanford-ner.jar'
st = StanfordNERTagger(model_filename=eng_model_filename, path_to_jar=my_path_to_jar)
st.tag('Rami Eid is studying at Stony Brook University in NY'.split())
中长:
见
我正在尝试实例化 StanfordNERTagger
。这就是我正在尝试的:
st = StanfordNERTagger("/Users/attitude/Desktop/english.all.3class.caseless.distsim.crf.ser.gz","/Users/attitude/Desktop/stanford-ner-2015-12-09/stanford-ner.jar")
我已将 CLASSPATH
变量设置为 /Users/attitude/Desktop/stanford-ner-2015-12-09/stanford-ner.jar
(我还尝试将父文件夹作为值 - /Users/attitude/Desktop/stanford-ner-2015-12-09
)。
但是,我收到此错误:
LookupError: Could not find stanford-ner.jar jar file at /Users/attitude/Desktop/stanford-ner-2015-12-09/stanford-ner.jar
.
我已经完成了这两个答案中提到的所有内容 - this and
OS X Yosemite - Python 2.7.
TL;DR:
不设置环境变量,使用关键字参数,model_filename
和path_to_jar
from nltk.tag import StanfordNERTagger
stanford_ner_dir = '/home/alvas/stanford-ner/'
eng_model_filename= stanford_ner_dir + 'classifiers/english.all.3class.distsim.crf.ser.gz'
my_path_to_jar= stanford_ner_dir + 'stanford-ner.jar'
st = StanfordNERTagger(model_filename=eng_model_filename, path_to_jar=my_path_to_jar)
st.tag('Rami Eid is studying at Stony Brook University in NY'.split())
中长:
见