File size: 503 Bytes
b384e43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Normalizer:

    def __init__(self):
        pass

    def remove_repetitions(self, text):
        first_ocurrences = []
        for sentence in text.split("."):
            if sentence not in first_ocurrences:
                first_ocurrences.append(sentence)
        return '.'.join(first_ocurrences)

    def trim_last_sentence(self, text):
        return text[:text.rfind(".")+1]
            
    def clean_txt(self, text):
        return self.trim_last_sentence(self.remove_repetitions(text))