File size: 480 Bytes
f19cca7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import pandas as pd
import re
from underthesea import word_tokenize
import unicodedata
def clean_text(text):
text = text.replace('\xa0', ' ') # Thay thế non-breaking space
text = unicodedata.normalize("NFC", text)
text = re.sub(r'[^\x20-\x7E\u00A0-\u1EF9\u0100-\u017F]', '', text) # Loại bỏ ký tự không thuộc bảng Unicode mở rộng của tiếng Việt
return text.strip()
def segment_text(text):
return word_tokenize(text, format="text")
|