Spaces:
Runtime error
Runtime error
| # modules/data_loader.py | |
| import os | |
| from config.settings import DATA_PATH | |
| def load_texts(file_path: str = DATA_PATH) -> list: | |
| """ | |
| Load text data from a .txt file. | |
| Each line in the file is treated as a separate text entry. | |
| """ | |
| if not os.path.exists(file_path): | |
| raise FileNotFoundError(f"Data file not found: {file_path}") | |
| with open(file_path, "r", encoding="utf-8") as f: | |
| texts = [line.strip() for line in f.readlines() if line.strip()] | |
| return texts | |