Download utils.py from AI-Driven-Data-Driven/Arabic-Rag-Chatbot: direct link, hf CLI and curl.
- Browser
- Download file 536 Bytes
-
https://huggingface.co/spaces/AI-Driven-Data-Driven/Arabic-Rag-Chatbot/resolve/main/utils.py
- Command line
-
hf download hf://spaces/AI-Driven-Data-Driven/Arabic-Rag-Chatbot/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/AI-Driven-Data-Driven/Arabic-Rag-Chatbot/resolve/main/utils.py
536 Bytes
| # utils.py | |
| import re | |
| import logging | |
| def clean_text(text): | |
| # Remove special characters and multiple spaces | |
| text = re.sub(r'[^\w\s\u0600-\u06FF]', ' ', text) | |
| text = re.sub(r'\s+', ' ', text).strip() | |
| return text | |
| def setup_logger(name): | |
| logger = logging.getLogger(name) | |
| logger.setLevel(logging.INFO) | |
| handler = logging.StreamHandler() | |
| formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') | |
| handler.setFormatter(formatter) | |
| logger.addHandler(handler) | |
| return logger | |