- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我需要从网站中提取所有城市名称。我在以前的项目中使用了 beautifulSoup 和 RE,但在这个网站上,城市名称是常规文本的一部分,没有特定的格式。我找到了满足我要求的地理包 ( https://pypi.python.org/pypi/geograpy/0.3.7)。
地理学使用 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.
任何帮助将不胜感激
最佳答案
您可以通过将“.node”替换为“.label()”来解决此问题。
在你的问题中,你可以尝试替换
if (ne.node == 'GPE' or ne.node == 'PERSON') and ne[0][1] == 'NNP':
与
if (ne.label() == 'GPE' or ne.label() == 'PERSON') and ne[0][1] == 'NNP':
关于python - "NotImplementedError: Use label() to access a node label",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27341311/
我正在使用以下 gem 作为编辑器。 gem "wysihat-engine", "~> 0.1.13" 当我运行“rails generate wysihat”时,它会生成所有图像文件,但无法生成迁
我的Scrapy代码无效。我正在尝试抓取论坛,但收到错误。 这是我的代码: import scrapy, time class ForumSpiderSpider(scrapy.Spider):
为什么 gevent 会抛出这个错误?在 ipython、ubuntu 13 中运行它 In [1]: from gevent import monkey In [2]: monkey.patch_a
如何将 instance 属性标记为未在基类中实现? (与讨论将 class 属性标记为未实现的 this 问题不同,但也许我没有正确理解基类...) 例如我想要类似的东西 class Base():
系统信息 python 3.8.7 操作系统 11.1(大苏尔) 通过 brew install python@3.8 安装的 Python 要在 Big Sur 和最有可能的旧版本上重现: impo
我正在阅读一篇关于布隆过滤器的文章,https://en.wikipedia.org/wiki/Bloom_filter ,其中一个表达式是为散列函数的最佳数量导出的。我想重现 m 的简化情况的计算=
我正在尝试使用 ActiveJob将诸如电子邮件调度之类的作业排队,但我得到一个 NotImplementedError (Use a queueing backend to enqueue jobs
我需要实现一个具有数百种方法的接口(interface)(ResultSet)。 现在,我将只实现这些方法的一个子集,抛出 NotImplementedError为其他人。 在 Java 中,我找到了
这是我的代码: package example object Lists { def max(xs: List[Int]): Int = { if(xs.isEmpty){
我正在使用 django 和 Google App Engine。我无法确定错误来自哪里,因为如果我在本地使用它,我的网站就会正常运行。在我将其部署到 GAE 上之后,它工作正常,但是当使用 goog
import torch import torch.nn as nn device = torch.device('cuda' if torch.cuda.is_available() else 'c
我的 scrapy 代码不工作,我不知道!我想抓取宜家网站,我首先设计了一个 CrawlSpider,它不够具体,无法检索网页的每个链接。所以我设计了一个带有 yield 请求方法的基本 Spider
是为了提醒你自己和你的团队正确实现类(class)吗?我没有完全使用这样的抽象类: class RectangularRoom(object): def __init__(self, widt
尝试在本地预编译 Assets 时出现以下问题 RAILS_ENV=production bundle exec rake assets:precompile rake aborted! Sprock
在我的 Rails 应用程序 (4.2.4) 中,我一直在尝试让异步邮件发送工作。 我安装了 delay_job 作为我的队列适配器,并在几个地方将它设置为适配器:config/application
这个问题在这里已经有了答案: Jupyter Notebook with Python 3.8 - NotImplementedError (4 个答案) 关闭 3 年前。 尝试在本地主机上构建 j
我在 azure 上上传时遇到问题 https://learn.microsoft.com/pl-pl/azure/machine-learning/how-to-access-data-intera
我想使用 pandas 中的 fillna 命令来估算数据帧。这是我的代码片段: import glob import pandas as pd files=glob.glob("IN.201*.cs
服务器JSON使用retrofit2和rxjava2进行数据解析。转到CompanyAdapter类时,数据获取并成功存储在List中,然后给出上述错误。 MainActivity.kt priva
我想使用 pandas 中的 fillna 命令来估算数据帧。这是我的代码片段: import glob import pandas as pd files=glob.glob("IN.201*.cs
我是一名优秀的程序员,十分优秀!