I am trying to remove suffixes but for some reason, it is not working. Code is:
# Stemming
suffix_list = ['-ed', '-ing', '-s']
for word in range(len(output)): # loop
# range returns the sequence, len checks the lenght
for suffix in range(len(suffix_list)):
# .endswith checks x in both
if output[word].endswith(suffix_list[suffix]):
# .removesuffix removes from output if in suffix_list
print(output[word].removesuffix(suffix_list[suffix]))
return output
print(textPreprocessing("I'm gathering herbs."))
print(textPreprocessing("When life gives you lemons, make lemonade"))
Outcome is:
gather
herb
['im', 'gathering', 'herbs']
give
lemon
['life', 'gives', 'you', 'lemons', 'make', 'lemonade']
Where it should be:
['im', 'gather', 'herbs']
['life', 'give', 'you', 'lemon', 'make', 'lemonade']
Any help? I feel like I am missing something obvious...