'When one criterion works, the other one does not work

Although there are other criteria, it seems that these two criteria clashes.

-Any words ending with 's' should remove it (e.g., 'gaps' -> 'gap', 'runs' -> 'run')

-Any words that has no vowels are excepted (e.g., 'CMPS', 'BTS')

Also I wanted to repeat until no more changes occur. I assumed that 10 times is enough so I used for loop and an pylint error appeared

source.py:10:8: W0612: Unused variable 'reapeat' (unused-variable)

how can I fix ? Those criteria are under remove plurals

def pos(sentence):
"""input parameter sentence (type string), and 
returns a string that stemmed all words from the given sentence"""
to_list = sentence.strip().split()
copy_list = sentence.strip().split()
vowels = "aeiou"


for repeat in range(10):
    for words in range(len(to_list)):
        
        length_words = len(to_list[words])
        

            
        #remove ownership
        if "'" in to_list[words]:
            length_words = length_words - 2
            to_list[words] = copy_list[words][:length_words]
            length_words = len(to_list[words])

        #remove plurals   
        if to_list[words].lower().endswith("s"):
            
            if to_list[words][-2] in vowels:
                to_list[words] = copy_list[words]
                
            else:
                length_words = length_words - 1
                to_list[words] = copy_list[words][:length_words]
                
        
            for chars in range(len(to_list[words])):
                if not(vowels in to_list[words][chars].lower()) is True:
                    to_list[words] = copy_list[words]
                    
            length_words = len(to_list[words])
            

            
        if to_list[words].lower().endswith("ss") or to_list[words].lower().endswith("us"):
            to_list[words] = copy_list[words]
            
        if to_list[words].lower().endswith("ies"):
            length_words = length_words - 2
            to_list[words] = copy_list[words][:length_words]
            
            if len(to_list[words]) <= 2:
                to_list[words] = copy_list[words][:length_words + 1]
            
            length_words = len(to_list[words])
        
        if to_list[words].lower().endswith("ves"):
            if len(to_list[words][:length_words - 3]) <= 2:
                to_list[words] = copy_list[words].replace("ves", "fe")
            else:
                to_list[words] = copy_list[words].replace("ves", "f")
        
       
    
return " ".join(to_list)

Inputs

stemmed = pos('it\'s name was theirs\' to say and with gaps they smelled gas and this was not okay.')

stemmed = pos("I went to BTS concert with my bonus pay and I cried there as my heart melted away from their singing, it was utterly beautiful I just felt possessed")

Expected outputs

it name was their to say and with gap they smell gas and this was not okay.
I went to BTS concert with my bonus pay and I cri there as my heart melt away from their singing, it was utt beautiful I just felt possess

My outputs

it name was their to say and with gap they smell gas and this was not okay.
I went to BT concert with my bonus pay and I cri there as my heart melt away from their singing, it was utt beautiful I just felt posses


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source