I have a list of words and a list of stem rules. I need to stem the words that their sufixes are in the stem rules list.I got a hint from a friend that i can use pipeline methods
For example if i have : stem=['less','ship','ing','les','ly','es','s'] text=['friends','friendly','keeping','friendship']
i should get :'friend','friend','keep',friend'
rules = {'ness': '', 'ational': 'ate', 'ing': '', 'sses': 'ss'}
def stemx(inp:str): for x in rules: if inp[len(inp) - len(x):] == x: return inp[0:len(inp) - len(x)] + rules[x] return inp
print(stemx('singfds'))