File size: 957 Bytes
80e3316 b5a336b 8a92bc6 80e3316 b5a336b 8a92bc6 b5a336b c012df6 b5a336b b4f0989 |
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 31 32 33 34 35 36 37 38 39 40 41 |
import gradio as gr
import re
import os
import py_vncorenlp
from pyvi import ViTokenizer, ViPosTagger
def preprocess_text(text):
# Loại bỏ các ký tự đặc biệt và dấu câu
text = re.sub(r'[^\w\s]', '', text)
# Loại bỏ URL
text = re.sub(r'http\S+', '', text)
# Loại bỏ đường dẫn file
text = re.sub(r'\/\w+', '', text)
return text
def remove_escape_sequences(text):
escape_sequences = ['\n', '\t', '\r', '\\']
for sequence in escape_sequences:
text = text.replace(sequence, '')
return text
def remove_html_tags(text):
clean_text = re.sub(r'<[^>]*>', '', text)
return clean_text
def vi_word_segment(text):
output = ViTokenizer.tokenize(text)
return output
def process_text(text):
text = vi_word_segment(text)
return text
if __name__ == '__main__':
iface = gr.Interface(fn=process_text, inputs="text", outputs="text")
iface.launch(share=True) |