[text] Python function for removing stop words

Viewer

copydownloadembedprintName: Python function for removing stop words
  1. data_stopwords = requests.get(
  2.   "https://gist.githubusercontent.com/larsyencken/1440509/raw/53273c6c202b35ef00194d06751d8ef630e53df2/stopwords.txt"
  3. ).text
  4.  
  5.  
  6. def remove_stopwords(input_string):
  7.   dict_stopwords = {}
  8.   for val in data_stopwords.split("\n"):
  9.     dict_stopwords[val.strip()] = 1
  10.  
  11.   output_string = ""
  12.   for word in input_string.lower().split():
  13.     if (word in dict_stopwords):
  14.       continue
  15.     output_string += word + " "
  16.   output_string = output_string.strip()
  17.   return output_string
  18.  

Editor

You can edit this paste and save as new:


File Description
  • Python function for removing stop words
  • Paste Code
  • 27 Apr-2023
  • 519 Bytes
You can Share it: