From 942d392ebcd1625051b9da2f3e227c185ad579ff Mon Sep 17 00:00:00 2001 From: Gigi Date: Sun, 30 Mar 2025 00:36:47 +0000 Subject: [PATCH] Improve word boundary detection in prompt template selection using regex --- src/summarize_transcripts.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/summarize_transcripts.py b/src/summarize_transcripts.py index 610b4cb..51dc2b6 100755 --- a/src/summarize_transcripts.py +++ b/src/summarize_transcripts.py @@ -5,6 +5,7 @@ import sys from pathlib import Path import ollama import time +import re def read_transcript(transcript_file: Path) -> str: """Read the content of a transcript file.""" @@ -15,11 +16,14 @@ def load_prompt_template(transcript_text: str) -> str: """Load the appropriate prompt template based on transcript content.""" prompt_dir = Path("prompts") - # Check transcript content to determine appropriate prompt - if "blog post" in transcript_text.lower(): + # Convert to lowercase for case-insensitive matching + text = transcript_text.lower() + + # Check transcript content to determine appropriate prompt using regex word boundaries + if re.search(r'\bblog post\b', text): # "I want to write a blog post" prompt_file = prompt_dir / "blog_post.md" - elif "idea" in transcript_text.lower() and "app" in transcript_text.lower(): + elif re.search(r'\bidea\b', text) and re.search(r'\bapp\b', text): # "I have an idea for an app" prompt_file = prompt_dir / "idea_app.md" else: