MapReduce: ValueError: too many values to unpack (expected 2)
MapReduce: ValueError: too many values to unpack (expected 2)
我是 运行 MapReduce 中的以下 Python 代码:
from mrjob.job import MRJob
import collections
bigram = collections.defaultdict(float)
unigram = collections.defaultdict(float)
class MRWordFreqCount(MRJob):
def mapper(self, _, line):
# Now we loop over lines in the system input
line = line.strip().split()
# go through each word in sentence
i = 0
for word in line:
if i > 0:
hist = word
else:
hist = ''
word = CleanWord(word) # Get the new word
# If CleanWord didn't return a string, move on
if word == None: continue
i += 1
yield word.lower(), hist.lower(), 1.0
if __name__ == '__main__':
MRWordFreqCount.run()
我收到错误:ValueError:要解压的值太多(预期为 2),但我不明白为什么。有什么建议么?
我 运行 的 cmd 行代码是:
python myjob.py Test.txt --mapper
在 MapReduce 作业中,您只发出键值对。为此,您可以应用以下类型的策略:
yield (word.lower(), hist.lower()), 1.0
我是 运行 MapReduce 中的以下 Python 代码:
from mrjob.job import MRJob
import collections
bigram = collections.defaultdict(float)
unigram = collections.defaultdict(float)
class MRWordFreqCount(MRJob):
def mapper(self, _, line):
# Now we loop over lines in the system input
line = line.strip().split()
# go through each word in sentence
i = 0
for word in line:
if i > 0:
hist = word
else:
hist = ''
word = CleanWord(word) # Get the new word
# If CleanWord didn't return a string, move on
if word == None: continue
i += 1
yield word.lower(), hist.lower(), 1.0
if __name__ == '__main__':
MRWordFreqCount.run()
我收到错误:ValueError:要解压的值太多(预期为 2),但我不明白为什么。有什么建议么?
我 运行 的 cmd 行代码是:
python myjob.py Test.txt --mapper
在 MapReduce 作业中,您只发出键值对。为此,您可以应用以下类型的策略:
yield (word.lower(), hist.lower()), 1.0