【发布时间】:2014-08-06 16:04:13
【问题描述】:
我正在尝试建立一个倒排索引,但我仍然遇到同样的错误
ValueError:解包的值太多
它出现在我的这部分代码中:
def inverted_index(self, text):
terms = self.getTerms(text)
inverted = {}
for index, word in terms:
locations = inverted.setdefault(word)
locations.append(index)
return inverted
在“for inde, word in terms:”这一行更具体:
如果我打印术语,我会得到一个单词列表:
['12th', 'comput', 'olympiad', 'ciao', 'chiamo', 'alberto', 'lancellotti', 'scrivendo', 'primo', 'articolo', 'piccolo', 'motor', 'ricerca', 'manual']
有什么想法吗?
【问题讨论】: