I need to. Modify my mapper to count words after removing punctuation marks during mapping.
mapper is below:
import sys
sys.path.append('.')
for line in sys.stdin:
line = line.strip() #trim spaces from beginning and end
keys = line.split() #split line by space
for key in keys:
value = 1
print ("%s\t%d" % (key,value))
import sys import string sys.path.append('.') for line in sys.stdin: line = line.strip() # trim spaces from beginning and end modified_line = '' # create an empty string for modified line for ch in line: # go through all characters of line if ch not in string.punctuation: # if the character is not a punctuation, modified_line += ch # then add it to modified line keys = modified_line.split() # split line by space for key in keys: value = 1 print("%s\t%d" % (key, value))
Get Answers For Free
Most questions answered within 1 hours.