Download app/utils/query_parser.py from atharvp/courseAid: direct link, hf CLI and curl.
- Browser
- Download file 408 Bytes
-
https://huggingface.co/spaces/atharvp/courseAid/resolve/main/app/utils/query_parser.py
- Command line
-
hf download hf://spaces/atharvp/courseAid/app/utils/query_parser.py
-
curl -L -o query_parser.py https://huggingface.co/spaces/atharvp/courseAid/resolve/main/app/utils/query_parser.py
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 | |