Im stuck with a simple problem in mrjob mareduce framework: I want to get the average number of words in a given parragraph and i got this:
class LineAverage(MRJob):
def mapper(self, _, line):
numwords = len(line.split())
yield "words", numwords
yield "lines", 1
def reducer(self, key, values):
yield key, sum(values)
With this code, i get after reduce process, the total of lines and words in the text, but i dont know how to get the average by doing:
words/TotalOfLines
I am newbie in this model of programming, if anyone can illustrate this example it'll be very appreciated.
In the meantime, thank you so much for your attention and participation