0
votes

I'm running the following Python code in MapReduce:

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()

I get the error: ValueError: too many values to unpack (expected 2) but I can't figure out why. Any suggestions? The cmd line code I'm running is: python myjob.py Test.txt --mapper

1
You are returning 3 values from mapper whereas you can only return 2 it seems. - Eli Sadoff
Thank. Yes you are right - MrJobs mapper function only takes a key, value as an output. pythonhosted.org/mrjob/guides/… - user1761806

1 Answers

2
votes

In MapReduce job, you emit only key and value pair. To do this you may apply following type of strategy:

yield (word.lower(), hist.lower()), 1.0