File size: 814 Bytes
0eef561
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import re

def clean_sentence(sentence):
    # Remove "!", "?", ".", "(", ")" from the sentence
    sentence = re.sub(r"[!.?()]", "", sentence)
    
    # Replace " , " with an empty space
    sentence = re.sub(r" , ", " ", sentence)
    
    # Remove any trailing commas
    sentence = re.sub(r"^,|,$", "", sentence)
    
    # Strip spaces
    sentence = sentence.strip()
    
    # Remove any usernames
    words = sentence.split(", ")
    result = []
    for word in words:
        word = word.strip()
        if word == 'v':
            result.append(word)
            continue
        if len(word) < 2:
            continue
        if any(char.isdigit() for char in word) and word not in ["1girl", "1boy", "1koma", "1other"]:
            continue
        result.append(word)
    
    return ", ".join(result)