c:\Python\lib\site-packages\ipykernel_launcher.py:15: DeprecationWarning: The StanfordDependencyParser will be deprecated Please use nltk.parse.corenlp.StanforCoreNLPDependencyParser instead. from ipykernel import kernelapp as app --------------------------------------------------------------------------- TypeError Traceback (most recent call last) in () 13 pcfg_path = 'edu\stanford\nlp\models\lexparser\chinesePCFG.ser.gz' 14 ---> 15 parser = stanford.StanfordDependencyParser(path_to_jar=parser_path,path_to_models= model_path,model_path=pcfg_path) 16 sentence = parser.raw_parse(seg_str) 17 for line in sentence: c:\Python\lib\site-packages\nltk\parse\stanford.py in __init__(self, *args, **kwargs) 351 DeprecationWarning, stacklevel=2) 352 --> 353 super(StanfordDependencyParser, self).__init__(*args, **kwargs) 354 355 def _make_tree(self, result): TypeError: __init__() got an unexpected keyword argument 'path_to_models'
时间: 2023-08-25 11:14:28 浏览: 201
python 3.74 运行import numpy as np 报错lib\site-packages\numpy\__init__.py
看起来你使用的 `StanfordDependencyParser` 类已经被标记为废弃了,并建议使用 `StanfordCoreNLPDependencyParser` 类代替。请尝试使用 `nltk.parse.corenlp.StanfordCoreNLPDependencyParser` 类代替 `StanfordDependencyParser` 类,代码如下:
```
from nltk.parse.corenlp import StanfordCoreNLPDependencyParser
parser = StanfordCoreNLPDependencyParser(url='http://localhost:9000')
result = parser.raw_parse('Your sentence here')
```
这里的 `url` 参数是指向 CoreNLP 服务器的地址。你需要先启动一个 CoreNLP 服务器,然后将 `url` 参数设置为该服务器的地址。你还需要安装 `stanford-corenlp` 包和 `pycorenlp` 包。如果你仍然遇到问题,请提供更多的错误信息和代码上下文。
阅读全文