zaryanezrya

mapper

May 25th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #!/usr/bin/env python
  2. """mapper.py"""
  3.  
  4. import sys
  5.  
  6. # input comes from STDIN (standard input)
  7. for line in sys.stdin:
  8. # remove leading and trailing whitespace
  9. line = line.strip()
  10. # split the line into words
  11. words = line.split()
  12. # increase counters
  13. for word in words:
  14. # write the results to STDOUT (standard output);
  15. # what we output here will be the input for the
  16. # Reduce step, i.e. the input for reducer.py
  17. #
  18. # tab-delimited; the trivial word count is 1
  19. print '%s\t%s' % (word, 1)
Add Comment
Please, Sign In to add comment