Get rid of stopwords and punctuation
问题 I'm struggling with NLTK stopword. Here's my bit of code.. Could someone tell me what's wrong? from nltk.corpus import stopwords def removeStopwords( palabras ): return [ word for word in palabras if word not in stopwords.words('spanish') ] palabras = ''' my text is here ''' 回答1: Your problem is that the iterator for a string returns each character not each word. For example: >>> palabras = "Buenos dias" >>> [c for c in palabras] ['B', 'u', 'e', 'n', 'a', 's', ' ', 'd', 'i', 'a', 's'] You