Python Geograpy无法运行演示
我正在尝试运行python的地理图 我使用这两种方法安装了geographyPython Geograpy无法运行演示,python,nlp,geograpy,Python,Nlp,Geograpy,我正在尝试运行python的地理图 我使用这两种方法安装了geography pip install geograpy 及 我还确保所有nltk安装正确。 我安装了geograpy使用的所有依赖项。 我对extraction.py做了以下更改 if (ne.node == 'GPE' or ne.node == 'PERSON') and ne[0][1] == 'NNP': to if (ne.label() == 'GPE' or ne.label() == 'PERSON') and
pip install geograpy
及
我还确保所有nltk安装正确。
我安装了geograpy使用的所有依赖项。
我对extraction.py做了以下更改
if (ne.node == 'GPE' or ne.node == 'PERSON') and ne[0][1] == 'NNP':
to
if (ne.label() == 'GPE' or ne.label() == 'PERSON') and ne[0][1] == 'NNP':
我正在运行的演示代码是
import geograpy
url = 'http://www.gutenberg.ca/ebooks/doyleac-casebookofsherlockholmes/doyleac-casebookofsherlockholmes-00-h.html'
places = geograpy.get_place_context(url=url)
print places.country_mentions
print places.region_mentions
print places.city_mentions
然而,我得到了这个错误
if (ne.label() == 'GPE' or ne.label() == 'PERSON') and ne[0][1] == 'NNP':
AttributeError: 'Tree' object has no attribute 'label'
如果我把extraction.py改回
if (ne.node == 'GPE' or ne.node == 'PERSON') and ne[0][1] == 'NNP':
我得到这个错误:
File "C:\Program Files (x86)\Python27\lib\site-packages\geograpy-0.3.7-py2.7.egg\geograpy\places.py", line 174, in set_cities
self.country_cities[country.name] = []
AttributeError: 'NoneType' object has no attribute 'name'
我还将提到我使用的是NLTK 3,但geograpy将其降级为NLTK2.0.5
外面有人请帮忙!谢谢我也遇到了同样的问题。它只需要在位于中的palces.py文件中更改正确的变量名 C:\Users\Naima\AppData\Roaming\Python\Python27\site packages\geograpy\places.py 转到places.py文件中的第174行,将country.name替换为country_name,如下所示:
self.country_cities[country_name] = []
希望这能奏效 我也面临同样的问题。它只需要在位于中的palces.py文件中更改正确的变量名 C:\Users\Naima\AppData\Roaming\Python\Python27\site packages\geograpy\places.py 转到places.py文件中的第174行,将country.name替换为country_name,如下所示:
self.country_cities[country_name] = []
希望这能奏效 您可能需要使用Geography3,而您可能需要使用Geography3