- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
您好,我正在 NLTK3 中尝试这段代码:-我设法以某种方式修复了第 6 行,以便与 NLTK 的版本 3 一起使用。但是 for 循环仍然不返回任何东西。
import nltk
sample = """ some random text content with names and countries etc"""
sentences = nltk.sent_tokenize(sample)
tokenized_sentences = [nltk.word_tokenize(sentence) for sentence in sentences]
tagged_sentences = [nltk.pos_tag(sentence) for sentence in tokenized_sentences]
chunked_sentences=nltk.chunk.ne_chunk_sents(tagged_sentences) #Managed to fix this to work with version_3
for i in chunked_sentences:
if hasattr(i,'label'):
if i.label()=='NE':
print i
另外,如果我尝试调试,我会看到这个输出:
for i in chunked_sentences:
if hasattr(i,'label') and i.label:
print i.label
S
S
S
S
S
S
S
S
那我如何检查它是否为“NE”。 NLTK-3 有问题,我真的无法弄清楚。请帮忙
最佳答案
您似乎在遍历句子。我假设您想遍历句子中包含的各个节点。
它应该像这样工作:
for sentence in chunked_sentences:
for token in sentence:
if hasattr(token,'label') and token.label() == 'NE':
print token
编辑:为了将来引用,让我知道您正在遍历句子这一事实的原因很简单,即句子的根节点通常标记为“S”。
关于python - 在 NLTK3 中遍历 ne block 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27212050/
我正在考虑通过慢速卫星连接创建数据查询 WCF 服务,我真的很喜欢 WCF 数据服务。我看到的问题是 HTTP 是一种非常冗长的格式,由于我所做的一切都是内部和 .NET,是否可以使用 NetTcpB
官方 MongoDB api 对 $ne 写的很少 http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24ne
当我尝试运行此查询时,我正在使用 mysql: Order.findAll({ where: { end_date: { $ne: null, }, }, });
我收藏的文档 rooms具有以下结构: { "_id": { "$oid": "4edaaa4a8d285b9311eb63ab" }, "users": [ {
我正在使用一开始具有以下结构的图表,但是我很难理解何时将其评估为true。 {{- if and .Values.vpceIngress.enabled .Values.http.paths (ne
我的 $ne : "" 无法与 pymongo 正常工作。 hashtable['ACR-WEB-01']=db.logs.find({"host_name" : "WEB-01"}, {"servi
我想获取一些文档,其中字段可能是$in某个数组(如果设置了过滤器,则进行条件查询)。 但是,我还需要无条件检查同一字段是否为 $ne: null。我知道 $in: [some value] 可用于防止
我正在尝试使用如下插入的数据运行以下查询。无论出于何种原因,值中为 0 的 $ne 似乎都不起作用。我使用 v2.0.4 在 linux 和 mac 上都试过了。还使用 mongo shell 运行了
我们有两个类,分别是“Parent”和“child”,如下所示: class Parent { parent_AddUser() { // add user code for
我一直在尝试创建一个奇特的 oh-my-zsh 主题,但不幸的是我遇到了一个恼人的障碍。 eval gray='$FG[245]' yellow='226' ret=$? # error check
我正在尝试排除某些行政区名称(例如布鲁克林、皇后区和史泰登岛)的查询,我只能排除一个,但不知道如何排除多个 只排除一个:db.rest.find({ borough : {$ne : "布鲁克林"}}
第一次在 Rails 项目上使用 Mongoid。 分机号是什么 .ne 以这样的作用域方法表示: scope :subscribed, -> { where( :unsubscri
数据: db.inventory.insertMany([ { _id: 1, item: null }, { _id: 2 }, { _id: 3, ite
db.test.find().pretty(); { "_id" : ObjectId("5537f2cfba0bf10870747d7e"), "a" : 1
我正在尝试查找 tipo=CD 和 canciones 不包含具有 title=Pajaritos 和 cancion=2 的子文档的所有文档> 这就是我想在 canciones 字段中实现的目标:
我一直在尝试执行以下 UNIX shell 脚本,但它不起作用。我通过 KornShell (ksh) 运行它。 echo $?; if [ $? -ne 0 ] then failed $LINE
所以我有如下所示的这一系列整数 from pandas import Series s = Series([1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1
假设,我想将新项目保存/创建到 DynamoDb 表中,当且仅当不存在任何现有项目包含与我设置的值相同的 referenceId 时。 就我而言,如果表中没有任何其他 withReferenceId=
在 Android 应用程序中,我想根据以下格式的坐标设置地理点 50 27.858N,004 57.146E。我阅读了以下主题 how to convert coordinates to geoPo
我在 Express Node.js 服务器上运行了以下两个文件: 首页.js var express = require('express') var sequelize = require('se
我是一名优秀的程序员,十分优秀!