Spaces:
Running
on
Zero
Running
on
Zero
gokaygokay
commited on
Commit
•
cb6599c
1
Parent(s):
b5c347a
Update app.py
Browse files
app.py
CHANGED
@@ -30,11 +30,11 @@ def modify_caption(caption: str) -> str:
|
|
30 |
|
31 |
# Create a regex pattern to match any of the prefixes
|
32 |
pattern = '|'.join([re.escape(opening) for opening, _ in prefix_substrings])
|
33 |
-
replacers = {opening: replacer for opening, replacer in prefix_substrings}
|
34 |
|
35 |
# Function to replace matched prefix with its corresponding replacement
|
36 |
def replace_fn(match):
|
37 |
-
return replacers[match.group(0)]
|
38 |
|
39 |
# Apply the regex to the caption
|
40 |
modified_caption = re.sub(pattern, replace_fn, caption, count=1, flags=re.IGNORECASE)
|
|
|
30 |
|
31 |
# Create a regex pattern to match any of the prefixes
|
32 |
pattern = '|'.join([re.escape(opening) for opening, _ in prefix_substrings])
|
33 |
+
replacers = {opening.lower(): replacer for opening, replacer in prefix_substrings}
|
34 |
|
35 |
# Function to replace matched prefix with its corresponding replacement
|
36 |
def replace_fn(match):
|
37 |
+
return replacers[match.group(0).lower()]
|
38 |
|
39 |
# Apply the regex to the caption
|
40 |
modified_caption = re.sub(pattern, replace_fn, caption, count=1, flags=re.IGNORECASE)
|