Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

remove stopwords from list of strings python

from nltk.corpus import stopwords
stopwords=set(stopwords.words('english'))

data =['I really love writing journals','The mat is very comfortable and I will buy it again likes','The mousepad is smooth']

def remove_stopwords(data):
    output_array=[]
    for sentence in data:
        temp_list=[]
        for word in sentence.split():
            if word.lower() not in stopwords:
                temp_list.append(word)
        output_array.append(' '.join(temp_list))
    return output_array





output=remove_stopwords(data)

print(output)
['really love writing journals','mat comfortable buy likes', 'mousepad smooth']
Comment

PREVIOUS NEXT
Code Example
Python :: load csv file using pandas 
Python :: python yyyymmdd 
Python :: python import stringio 
Python :: python replace newline 
Python :: restart computer py 
Python :: pygame tetris game tutorial 
Python :: print decimal formatting in python 
Python :: delete object from table django 
Python :: how to make a tick update in python 
Python :: subprocess the system cannot find the file specified 
Python :: pickle dump 
Python :: confusion matrix from two columns pandas dataframe 
Python :: plt.savefig without showing 
Python :: Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory. 
Python :: how to get the index of a value in pandas dataframe 
Python :: python how often element in list 
Python :: python valeur de pi 
Python :: use of the word bruh over time 
Python :: pytest installation windows 
Python :: pandas rename index values 
Python :: web scraping linkedin profiles python jupyter 
Python :: how to convert 24 hours to 12 hours in python 
Python :: opencv face detection code python webcam 
Python :: remove consecutive duplicates python 
Python :: python endswith list 
Python :: split dataset into train, test and validation sets 
Python :: how to take two integers as input in python 
Python :: kivy changing screen in python 
Python :: df to np array 
Python :: check if numpy arrays are equal 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =