Add comma support to vocabulary patterns

- Use [!,] character class to catch both 'Fantastic!' and 'Fantastic,'
- SpongeBob phrases always end with ! - emphasis carries the emotion
- Added Brilliant patterns (both cases)
- Cleaner pattern structure with captured whitespace group
This commit is contained in:
BarnacleBoy 2026-05-09 20:58:04 +00:00
parent d97e28467d
commit 150178bc12

View file

@ -35,49 +35,49 @@ OPENING_INTERJECTIONS = [
# Vocabulary replacements - case-insensitive regex patterns
# Format: (pattern, replacement)
# Uses [!,] to match both exclamation and comma contexts
# SpongeBob phrases always end with ! - the emphasis carries the emotion
VOCABULARY_PATTERNS = [
# Exclamations (surprise, excitement) - standalone or at start
(r'\bWow!\s', 'Tartar sauce! '),
(r'\bWow!\Z', 'Tartar sauce!'),
(r'\bWow,', 'Tartar sauce,'),
# Wow - surprise/excitement
(r'\bWow[!,](\s)', r'Tartar sauce!\1'), # Wow! or Wow, → Tartar sauce!
(r'\bWow!\Z', 'Tartar sauce!'), # Wow! at end of string
(r'\bWow,', 'Tartar sauce,'), # Keep existing comma pattern for variety
# Amazing variations
(r'\b[Aa]mazing!\s', 'Holy Krabby Patties! '),
# Amazing - praise/excitement
(r'\b[Aa]mazing[!,](\s)', r'Holy Krabby Patties!\1'),
(r'\b[Aa]mazing!\Z', 'Holy Krabby Patties!'),
# Excellent
(r'\b[Ee]xcellent!\s', 'Holy fish paste! '),
# Excellent -satisfaction
(r'\b[Ee]xcellent[!,](\s)', r'Holy fish paste!\1'),
(r'\b[Ee]xcellent!\Z', 'Holy fish paste!'),
# Great
(r'\bGreat!\s', 'Barnacles! '),
# Great -emphasis (case-sensitive, only "Great" not "great")
(r'\bGreat[!,](\s)', r'Barnacles!\1'),
(r'\bGreat!\Z', 'Barnacles!'),
# Perfect
(r'\b[Pp]erfect!\s', 'Holy cephalopod! '),
# Perfect - satisfaction
(r'\b[Pp]erfect[!,](\s)', r'Holy cephalopod!\1'),
(r'\b[Pp]erfect!\Z', 'Holy cephalopod!'),
# Fantastic
(r'\b[Ff]antastic!\s', 'Holy shrimp! '),
# Fantastic - excitement/praise
(r'\b[Ff]antastic[!,](\s)', r'Holy shrimp!\1'),
(r'\b[Ff]antastic!\Z', 'Holy shrimp!'),
# Brilliant
(r'\bBrilliant!', 'Great Barrier Reef!'),
# Brilliant - praise (British flavor, matches both cases)
(r'\b[Bb]rilliant[!,](\s)', r'Great Barrier Reef!\1'),
(r'\b[Bb]rilliant!\Z', 'Great Barrier Reef!'),
# Damn frustration
(r'\b[Dd]amn!', 'Barnacles!'),
(r'\b[Dd]amn,', 'Aw, barnacles,'),
# Damn - frustration/mild swearing
(r'\b[Dd]amn!', 'Barnacles!'), # Damn! → Barnacles!
(r'\b[Dd]amn,', 'Aw, barnacles,'), # Damn, → Aw, barnacles,
# Ugh frustration
(r'\bUgh!', 'Fish paste!'),
(r'\bUgh,', 'Aw, fish paste!'),
# Ugh - frustration
(r'\bUgh!', 'Fish paste!'), # Ugh! → Fish paste!
(r'\bUgh,', 'Aw, fish paste!'), # Ugh, → Aw, fish paste!
# Fantastic praise
(r'\b[Ff]antastic!', 'Mother of Pearl!'),
# Common openers
(r'\bWell,', "Flappin' flounders,"),
(r'\bOh,', 'Oh, barnacles,'),
# Common openers - conversational fillers
(r'\bWell,', "Flappin' flounders,"), # Well, → Flappin' flounders,
(r'\bOh,', 'Oh, barnacles,'), # Oh, → Oh, barnacles,
]
# Patterns to preserve (never transform)
@ -151,7 +151,7 @@ def transform_vocabulary(response_text: str, session_id: str = "", model: str =
)
if not already_interjected:
# Prepend interjection with newline separator
# Prepend interjection with space separator
transformed = f"{interjection} {transformed}"
logger.info(f"[spongebob-vocab] Prepended interjection: {interjection}")