Spaces:
Runtime error
Runtime error
Download processor_regex.py from yuvarajareddy001/optimized-llm-log-classification: direct link, hf CLI and curl.
- Browser
- Download file 961 Bytes
-
https://huggingface.co/spaces/yuvarajareddy001/optimized-llm-log-classification/resolve/main/processor_regex.py
- Command line
-
hf download hf://spaces/yuvarajareddy001/optimized-llm-log-classification/processor_regex.py
-
curl -L -o processor_regex.py https://huggingface.co/spaces/yuvarajareddy001/optimized-llm-log-classification/resolve/main/processor_regex.py
961 Bytes
| import re | |
| def classify_with_regex(log_message): | |
| regex_patterns = { | |
| r"User User\d+ logged (in|out).": "User Action", | |
| r"Backup (started|ended) at .*": "System Notification", | |
| r"Backup completed successfully.": "System Notification", | |
| r"System updated to version .*": "System Notification", | |
| r"File .* uploaded successfully by user .*": "System Notification", | |
| r"Disk cleanup completed successfully.": "System Notification", | |
| r"System reboot initiated by user .*": "System Notification", | |
| r"Account with ID .* created by .*": "User Action" | |
| } | |
| for pattern, label in regex_patterns.items(): | |
| if re.search(pattern, log_message): | |
| return label | |
| return None | |
| if __name__ == "__main__": | |
| print(classify_with_regex("Backup completed successfully.")) | |
| print(classify_with_regex("Account with ID 1234 created by User1.")) | |
| print(classify_with_regex("Hey Bro, chill ya!")) | |