我需要从网站中提取所有城市名称。我在以前的项目中使用了RE的beautifulSoup,但在本网站上,城市名称是常规文本的一部分,没有特定的格式。我找到符合我要求的地理包裹(https://pypi.python.org/pypi/geograpy/0.3.7)。“NotImplementedError:使用标签()访问节点标签”
Geograpy使用NLTK包。我安装了所有NLTK的模型和数据包,但它不断抛出这个错误:
>>> import geograpy
>>> places = geograpy.get_place_context(url="http://www.state.gov/misc/list/")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\geograpy\__init__.py", line 6, in get_place_context
e.find_entities()
File "C:\Python27\lib\site-packages\geograpy\extraction.py", line 31, in find_entities
if (ne.node == 'GPE' or ne.node == 'PERSON') and ne[0][1] == 'NNP':
File "C:\Python27\lib\site-packages\nltk\tree.py", line 198, in _get_node
raise NotImplementedError("Use label() to access a nod label.")
NotImplementedError: Use label() to access a node label.
任何帮助,将不胜感激
感谢您的回答。我自己想到了这一点。我实际上希望有人能帮助我“修复”这个软件包。可能是有nltk经验的人。至于使用不同的包装,我一直在寻找类似的包装好几天,但还没有发现任何东西。 – Faisal 2014-12-09 13:54:32