Consider a file containing words separated by spaces; write a MapReduce program in Python, which counts the number of times each 3-word sequence appears in the file.
For example, consider the following file:
one two three seven one two three
three seven one
seven one two
The number of times each 3 word sequence appears in this file is:
"three seven one" 2
"four seven one two" 1
"one two three" 2
"seven one two" 2
"two three seven" 1
Code format:
from mrjob.job import MRJob
class MR3Nums(MRJob):
def mapper(self,_, line):
pass
def reducer(self,key, values):
pass
if __name__ == "__main__":
MR3Nums.run()