Question: Q. Now slightly modify the WordCount.py program. Call the new program WordCount2.py. Instead of counting how many words there are in the input documents (w.data),

Q. Now slightly modify the WordCount.py program. Call the new program WordCount2.py.
Instead of counting how many words there are in the input documents (w.data), modify the program to count how many words begin with the small letters a-n and how many begin with anything else.
The output file should look something like
a_to_n, 12
other, 21
Note - This has to run on a terminal through hadoop using this command - python WordCount2.py -r hadoop hdfs:///user/hadoop/w.data
Subject - Big Data Technologies
WordCount.py 1 from mrjob.job import MRJob 2 import re 3 4 WORD_RE = re. compile(r"[\w']+") 5 6 7 class MRWordCount (MRJob): 8 - def mapper(self, line): for word in WORD_RE.findall(line): yield word. lower(), 1 def combiner(self, word, counts): yield word, sum(counts) 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 def reducer(self, word, counts): yield word, sum(counts) if name __main__': MRWordCount.run()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
