尝试使用python中的geograpy库从文本中提取城市名称时出错

时间:2019-02-17 16:36:00

标签: python

这是我尝试过的代码

from geograpy.extraction import Extractor
    import geograpy

text = """Kadawatha Opposition Leader Mahinda Rajapaksa says that the whole  public administration has collapsed due to the constitution council’s arbitrary actions.
    The Opposition Leader said so in response to a query a journalised raised  after a meeting held in Malabe and Meegamuwa"""
    places = geograpy.get_place_context(text=text)
    print(places.places)

然后给出错误

enter image description here enter image description here

2 个答案:

答案 0 :(得分:0)

假设this是您正在使用的geography软件包,Install & Setup部分说您还需要下载他们正在使用的模型:

Geograpy使用NLTK进行实体识别,因此您还需要下载我们正在使用的模型。幸运的是,有一条命令可以帮您解决这个问题:

geograpy-nltk

您下载了模型吗?

答案 1 :(得分:0)

尝试将其卸载并使用以下命令进行安装:

pip install geograpy3