Python parsing to lower case and removing punctuation not functioning properly -
import string remove = dict.fromkeys(map(ord, '\n ' + string.punctuation)) open('data10.txt', 'r') f: line in f: word in line.split(): w = f.read().translate(remove) print(word.lower())
i have code here , reason, translate(remove)
leaving amount of punctuation in parsed file.
why reading whole file within loop?
try this:
import string remove = dict.fromkeys(map(ord, '\n ' + string.punctuation)) open('data10.txt', 'r') f: line in f: word in line.split(): word = word.translate(remove) print(word.lower())
this print our lower cased , stripped words, 1 per line. not sure if that's want.
Comments
Post a Comment