courseAid / app /utils /query_parser.py
atharvp's picture
fixed assistant errors
b74eb81
Raw History Blame Contribute Delete
408 Bytes
import re
def extract_courses_from_user_query(query:str):
pattern = r'\b[A-Z]{2}\d{4}\b'
return re.findall(pattern, query)
def extract_two_prof_names(text: str):
pattern = r'([A-Za-z]+\s+[A-Za-z]+)\s+(?:and|&)\s+([A-Za-z]+(?:\s+[A-Za-z]+)?)'
match = re.search(pattern, text, re.IGNORECASE)
if match:
return [match.group(1).strip(), match.group(2).strip()]
return None