Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a MapReduce program that counts the number of unique words in a given text file. Example Input: Lorem ipsum dolor sit amet, consectetur adipiscing
Write a MapReduce program that counts the number of unique words in a given text file.
Example Input:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec condimentum elit vel mauris varius, id laoreet tortor placerat.
Nulla scelerisque felis ac risus varius, sit amet luctus elit mattis.
Example Output:
"adipiscing"
"condimentum"
"consectetur"
"Donec"
"dolor"
"elit"
"felis"
id
"ipsum"
"laoreet"
"luctus"
"mattis"
"mauris"
"Nulla"
"placerat"
"risus"
"scelerisque"
"sit"
"tortor"
"vel"
"varius"
Problem#: WordCount With Stopwords
Write a MapReduce program that only counts nonstop words. List of stopwords are: the, and,
of a to in is it
Example Input:
This is a sample input text. It contains some common words such as the, and, of a and to
These stopwords should be removed in the output.
Example Output:
"common"
"contains"
"input"
"output"
"removed"
"sample"
"should"
"some"
"stopwords"
"text"
Problem#:
Let's consider a scenario where we are interested in counting the occurrences of word bigrams
instead of individual words. A word bigram refers to a pair of words that are adjacent to each
other in the text excluding bigrams that span across line breaks For example, given the line of
text "cat dog sheep horse," the corresponding bigrams would be cat "dog"dog "sheep"
and sheep "horse" To achieve this goal, we need to construct a map function and a reduce
function. The map function will emit each word bigram as a keyvalue pair, where the key
represents the bigram separated by a comma eg "cat,dog" and the value is set to
Please note that we will only consider bigrams that occur on the same line, and there is no need
to handle bigrams that cross line breaks.
Here's an example illustrating the input and output format:
Example Input:
a man a plan a canal panama there was a plan to build a canal in panama in panama a canal
was built
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started