I am having trouble creating code which removes stop words from a string input. Currently, here is my code:
stopWords = [ "a", "i", "it", "am", "at", "on", "in", "to", "too", "very", \
"of", "from", "here", "even", "the", "but", "and", "is", "my", \
"them", "then", "this", "that", "than", "though", "so", "are" ]
stemEndings = [ "-s", "-es", "-ed", "-er", "-ly" "-ing", "-'s", "-s'" ]
punctuation = [ ".", ",", ":", ";", "!", "?" ]
line = raw_input ("Type in lines, finish with a . at start of line only:")
while line != ".":
def remove_punctuation(input): #removes punctuation from input
output = ""
text= 0
while text<=(len(input)-1) :
if input[text] not in punctuation:
output=output + input[text]
text+=1
return output
newline= remove_punctuation(line)
newline= newline.lower()
What code could be added to remove stopWords from a string based on the stopWords list above? Thank you in advance.