Update app.py
Browse files
app.py
CHANGED
|
@@ -6,12 +6,9 @@ import re
|
|
| 6 |
import emoji
|
| 7 |
from urllib.parse import unquote
|
| 8 |
def filter_text_and_preserve_emojis(text):
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
# Use the findall method to keep allowed characters and emojis
|
| 13 |
-
filtered_text = ''.join(allowed_pattern.findall(text))
|
| 14 |
-
|
| 15 |
return filtered_text
|
| 16 |
def filter_non_alphanumeric(text):
|
| 17 |
# Use regular expressions to filter out non-alphanumeric characters
|
|
|
|
| 6 |
import emoji
|
| 7 |
from urllib.parse import unquote
|
| 8 |
def filter_text_and_preserve_emojis(text):
|
| 9 |
+
# Regular expression that allows letters, numbers, spaces, specific punctuation, and a broad range of Unicode characters for emojis
|
| 10 |
+
pattern = re.compile(r'[a-zA-Z0-9\s.,?!\'"]|[\U0001F600-\U0001F64F\U0001F300-\U0001F5FF\U0001F680-\U0001F6FF\U0001F700-\U0001F77F\U0001F780-\U0001F7FF\U0001F800-\U0001F8FF\U0001F900-\U0001F9FF\U0001FA00-\U0001FA6F\U0001FA70-\U0001FAFF\U00002702-\U000027B0\U000024C2-\U0001F251]+')
|
| 11 |
+
filtered_text = ''.join(pattern.findall(text))
|
|
|
|
|
|
|
|
|
|
| 12 |
return filtered_text
|
| 13 |
def filter_non_alphanumeric(text):
|
| 14 |
# Use regular expressions to filter out non-alphanumeric characters
|