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