Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,26 +6,18 @@ import streamlit as st
|
|
| 6 |
import re
|
| 7 |
|
| 8 |
def fix_bartpho_output(text: str) -> str:
|
| 9 |
-
|
| 10 |
-
BARTpho syllable tách từng âm tiết riêng lẻ nên hay bị dính.
|
| 11 |
-
Dùng underthesea để word tokenize rồi ghép lại đúng cách.
|
| 12 |
-
"""
|
| 13 |
-
import re
|
| 14 |
-
|
| 15 |
-
# Fix các pattern dính từ phổ biến nhất của BARTpho
|
| 16 |
-
# Thêm space giữa: chữ thường + chữ hoa
|
| 17 |
text = re.sub(
|
| 18 |
-
r'([a-
|
| 19 |
-
r'([A-
|
| 20 |
-
r'\1 \2',
|
|
|
|
| 21 |
)
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
# Xóa space thừa
|
| 27 |
text = re.sub(r' +', ' ', text).strip()
|
| 28 |
-
|
| 29 |
return text
|
| 30 |
|
| 31 |
|
|
|
|
| 6 |
import re
|
| 7 |
|
| 8 |
def fix_bartpho_output(text: str) -> str:
|
| 9 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
text = re.sub(
|
| 11 |
+
r'([a-zđàáâãèéêìíòóôõùúýăắặấầẩẫậ])'
|
| 12 |
+
r'([A-ZĐÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚÝĂẮẶẤẦẨẪẬ])',
|
| 13 |
+
r'\1 \2',
|
| 14 |
+
text
|
| 15 |
)
|
| 16 |
+
|
| 17 |
+
text = re.sub(r'([.!?,;:])([^\s])', r'\1 \2', text)
|
| 18 |
+
|
|
|
|
|
|
|
| 19 |
text = re.sub(r' +', ' ', text).strip()
|
| 20 |
+
|
| 21 |
return text
|
| 22 |
|
| 23 |
|