Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For running python Based MR tasks ,have a Look at:</p> <p><a href="http://hadoop.apache.org/docs/r1.1.2/streaming.html" rel="nofollow">http://hadoop.apache.org/docs/r1.1.2/streaming.html</a> <a href="http://www.michael-noll.com/tutorials/writing-an-hadoop-mapreduce-program-in-python/" rel="nofollow">http://www.michael-noll.com/tutorials/writing-an-hadoop-mapreduce-program-in-python/</a></p> <p>You need to design your code in Terms of Mapper - Reducer to enable Hadoop to execute your Python script. Read on the Map-Reduce Programming Paradigm before you can jump into writing the code. Its important to understand the MR programming paradigm and the role of {Key , value } pairs in solving the problem.</p> <pre><code>#Modified your above code to generate the required output import urllib2 import random from operator import itemgetter current_word = {} current_count = 0 story = 'http://sixty-north.com/c/t.txt' request = urllib2.Request(story) response = urllib2.urlopen(request) each_word = [] words = None count = 1 same_words ={} word = [] """ looping the entire file """ #Collect All the words into a list for line in response: #print "Line = " , line line_words = line.split() for word in line_words: # looping each line and extracting words each_word.append(word) #for every word collected, in dict same_words #if a key exists, such that key == word then increment Mapping Value by 1 # Else add word as new key with mapped value as 1 for words in each_word: if words.lower() not in same_words.keys() : same_words[words.lower()]=1 else: same_words[words.lower()]=same_words[words.lower()]+1 for each in same_words.keys(): print "word = ",each, ", count = ",same_words[each] </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload