Download document_processor.py from AI-Driven-Data-Driven/Arabic-Rag-Chatbot: direct link, hf CLI and curl.
- Browser
- Download file 518 Bytes
-
https://huggingface.co/spaces/AI-Driven-Data-Driven/Arabic-Rag-Chatbot/resolve/d12e375c0e9dee4ba08e229a9d87f820c4b42e2b/document_processor.py
- Command line
-
hf download hf://spaces/AI-Driven-Data-Driven/Arabic-Rag-Chatbot@d12e375c0e9dee4ba08e229a9d87f820c4b42e2b/document_processor.py
-
curl -L -o document_processor.py https://huggingface.co/spaces/AI-Driven-Data-Driven/Arabic-Rag-Chatbot/resolve/d12e375c0e9dee4ba08e229a9d87f820c4b42e2b/document_processor.py
518 Bytes
| # document_processor.py | |
| import os | |
| import glob | |
| from tqdm import tqdm | |
| import pandas as pd | |
| from utils import clean_text, setup_logger | |
| logger = setup_logger('document_processor') | |
| def load_single_document(file_path): | |
| try: | |
| with open(file_path, 'r', encoding='utf-8') as file: | |
| content = clean_text(file.read()) | |
| return pd.DataFrame([{'path': file_path, 'content': content}]) | |
| except Exception as e: | |
| logger.error(f"Error reading {file_path}: {e}") | |
| return pd.DataFrame() | |