Sentiment_Analysis / modules /data_loader.py
Pro-Coder's picture
Create modules/data_loader.py
c061cec verified
Raw
History Blame Contribute Delete
496 Bytes
# 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