【发布时间】:2021-03-15 13:22:02
【问题描述】:
我正在尝试基于图形的文本摘要。
sentences_rank_frek=[]
for sentence in copy_sent:
for word in sentence:
if word in freq:
sentences_rank_frek[sentence]+=freq[copy_sent[sentence][word]]
此代码给出错误:列表索引必须是整数或切片,而不是列表 我可以显示这个 freq[copy_sent[0][1]] = 4
【问题讨论】:
-
如果您的
sentence不是整数,您将无法访问列表sentences_rank_frek。 -
句子是整数
-
copy_sent[sentence][word]呢? -
copy_sent 是一个文本列表。// copy_sent[0][1] = "sale" // copy_sent[0]= 文本中的第一句
-
你是说你正在尝试使用文本访问列表
freq?
标签: python text nlp summarization