I'm getting this error while trying to remove punctuation from text.
train_pos_no_punctuation = remove_punctuation(train_pos)
def remove_punctuation(from_text):
table = str.maketrans('', '', string.punctuation)
stripped = [w.translate(table) for w in from_text]
return stripped
train_pos has type
<class 'list'>
and the following form:
[['hello', 'there', 'world!'], ['i', '"like"', 'potatoes.']]
After applying the function I want to get the result:
[['hello', 'there', 'world'], ['i', 'like', 'potatoes']]
What seems to be the problem?
答案 0 :(得分:1)
您有一份清单。
尝试:
train_pos_no_punctuation = [remove_punctuation(i) for i in train_pos]