我刚刚安装了python stanford nlp,这很好: -
pip install stanfordnlp
从python shell,我试图实例化包,我得到以下错误: -
>>> import stanfordnlp
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/shivajidutta/anaconda/lib/python2.7/site-packages/stanfordnlp/__init__.py", line 1, in <module>
from stanfordnlp.pipeline.core import Pipeline
File "/Users/shivajidutta/anaconda/lib/python2.7/site-packages/stanfordnlp/pipeline/core.py", line 9, in <module>
from stanfordnlp.pipeline.doc import Document
File "/Users/shivajidutta/anaconda/lib/python2.7/site-packages/stanfordnlp/pipeline/doc.py", line 175
return f"<{self.__class__.__name__} index={self.index};words={self.words}>"
^
SyntaxError: invalid syntax
这条线:
return f"<{self.__class__.__name__} index={self.index};words={self.words}>"
表示该程序包适用于Python 3.6或更高版本。它返回一个f-string,它是在3.6版本中引入的。您运行的是2.7版。
是时候升级?