I have the following class with methods:
class Trigger():
def getRidOfTrashPerSentence(self, line, stopwords):
countWord = 0
words = line.split()
for word in words:
if countWord == 0:
if word in stopwords:
sep = word
lineNew = line.split(sep, 1)[0]
countWord = countWord + 1
return(lineNew)
stopwords = ['regards', 'Regards']
def getRidOfTrash(self, aTranscript):
result = [self.getRidOfTrashPerSentence(line, self.stopwords) for line in aTranscript]
return(result)
What I would like to achieve with it is to cut of 'trash' in sentence after certain trigger words like ['regards', 'Regards']
So when I would insert a block like this:
aTranScript = [ "That's fine, regards Henk", "Allright great"]
I am looking for an output like this:
aTranScript = [ "That's fine, regards", "Allright great"]
However when I do this:
newFile = Trigger()
newContent = newFile.getRidOfTrash(aTranScript)
I only get "That's fine"
.
Any thoughts on how I can get both the strings