File size: 496 Bytes
c061cec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 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