Python NLTK包和其他依赖项出错

Python NLTK包和其他依赖项出错,python,nlp,stanford-nlp,named-entity-recognition,ner,Python,Nlp,Stanford Nlp,Named Entity Recognition,Ner,我已安装NLTK包和其他依赖项,并按如下方式设置环境变量: STANFORD_MODELS=/mnt/d/stanford-ner/stanford-ner-2018-10-16/classifiers/english.all.3class.distsim.crf.ser.gz:/mnt/d/stanford-ner/stanford-ner-2018-10-16/classifiers/english.muc.7class.distsim.crf.ser.gz:/mnt/d/stanford-

我已安装NLTK包和其他依赖项,并按如下方式设置环境变量:

STANFORD_MODELS=/mnt/d/stanford-ner/stanford-ner-2018-10-16/classifiers/english.all.3class.distsim.crf.ser.gz:/mnt/d/stanford-ner/stanford-ner-2018-10-16/classifiers/english.muc.7class.distsim.crf.ser.gz:/mnt/d/stanford-ner/stanford-ner-2018-10-16/classifiers/english.conll.4class.distsim.crf.ser.gz

CLASSPATH=/mnt/d/stanford-ner/stanford-ner-2018-10-16/stanford-ner.jar
当我尝试访问分类器时,如下所示:

stanford_classifier = os.environ.get('STANFORD_MODELS').split(':')[0]

stanford_ner_path = os.environ.get('CLASSPATH').split(':')[0]

st = StanfordNERTagger(stanford_classifier, stanford_ner_path, encoding='utf-8')
我得到以下错误。但我不明白是什么导致了这个错误

Error: Could not find or load main class edu.stanford.nlp.ie.crf.CRFClassifier
OSError: Java command failed : ['/mnt/c/Program Files (x86)/Common 
Files/Oracle/Java/javapath_target_1133041234/java.exe', '-mx1000m', '-cp', '/mnt/d/stanford-ner/stanford-ner-2018-10-16/stanford-ner.jar', 'edu.stanford.nlp.ie.crf.CRFClassifier', '-loadClassifier', '/mnt/d/stanford-ner/stanford-ner-2018-10-16/classifiers/english.all.3class.distsim.crf.ser.gz', '-textFile', '/tmp/tmpaiqclf_d', '-outputFormat', 'slashTags', '-tokenizerFactory', 'edu.stanford.nlp.process.WhitespaceTokenizer', '-tokenizerOptions', '"tokenizeNLs=false"', '-encoding', 'utf8']

我找到了这个问题的答案。我使用的是NLTK==3.4。From NLTK==3.3及以上斯坦福NLP(POS、NER、标记器)不作为NLTK.tag的一部分加载,而是从NLTK.parse.corenlp.CoreNLPParser加载。stackoverflow的答案可以在stackoverflow.com/questions/13883277/stanford parser和nltk/…中找到,官方文档的github链接是github.com/nltk/nltk/wiki/stanford-CoreNLP-API-in-nltk


其他信息如果您面临来自NER标记器或coreNLP API的任何其他解析器的超时问题,请按照dimazest中的说明增加超时限制。

大家好,我找到了这个问题的答案。我使用的是NLTK==3.4。From NLTK==3.3及以上斯坦福NLP(POS、NER、标记器)不作为NLTK.tag的一部分加载,而是从NLTK.parse.corenlp.CoreNLPParser加载。stackoverflow答案在中提供,官方文档的github链接在中。