Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Change the code to count how many words of different lengths are in the poems da

ID: 3735690 • Letter: C

Question

Change the code to count how many words of different lengths are in the poems data. Note that for this problem, the map function should output a pair with the format and with examples Length 8", 1> or Length 7", 1>, or similar. The reduce function should stay the same because it will only count the different lengths. To get the length of a string "theWord" in Java you need to use the function theWord.length0. For more Submit your code in txt and results as a screenshot the map java function // start of the map class import java.util.StringTokenizers 1 you need to add this line import java.io.IOException mport org-apache hadoop.lo import org.apache hadoop.mapreduce.Napper public class Hapit extends Happercobject, Text Text Inthritable> publie vold map (object key, Text value, Context context -your code should start here String mapinptn- no dusk- no proper tine of day-" napinput ·mapinput.tolovercase(); Stringtokenizer tokeniterator-new StringTokenizer mapinputtnAN- while (tokenlterator hasMozeTokens O) String theWord -tokeniterator next Token IntHritable intvalue-new IntWritable() Text word new Text(); word.setf thelord context write (word,valuel a -your code should end here 1/ end of the map elass

Explanation / Answer

Hi,

Below is the modified Map Class. As mentioned in the question, no change is required in Reduce class as it counts different lengths. Map function is changed so that it will create a Text as Length of the word as "Length 8" and it outputs <Text, IntWritable> as <key, value>. Changes are highlighted in Bold:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote