File size: 544 Bytes
949a823
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# model-fastapi/preprocessing.py
import re
import emoji

def clean_text(t):
    t = str(t).lower()
    t = re.sub(r"http\S+|www\.\S+", "", t) 
    t = re.sub(r"@\w+", "", t)             
    t = re.sub(r"#(\w+)", r"\1", t)        
    t = re.sub(r"\s+", " ", t).strip()     
    # Jika Anda menggunakan emoji.replace_emoji() di Colab, pastikan versi Python Anda mendukungnya, atau gunakan pustaka yang diimpor.
    # Contoh: t = emoji.replace_emoji(t, replace="")
    return t

def preprocess_text(text: str) -> str:
    return clean_text(text)