I have created a dictionary that I use to use to bring a variety of words to its base form.
dictionary = {'sunny': 'sun', 'banking': 'bank'}
def stemmingWords(sentence, dictionary):
for word in sentence.split():
temp = []
if word in dictionary:
word = dictionary[word]
temp.append(word)
sentence = ' '.join(temp)
return(sentence)
Now if print the separate words it seems to work. However when I insert a whole sentence and I would like an updated version of this sentence something seems to go wrong. For example if I do:
sentence = "the sun us shining"
new_sentence = stemmingWords(sentence, dictionary)
print(new_sentence)
Gives me "shining". While I am looking "the sunny in shining".
Any thoughts on what goes wrong here?