Pro-Coder commited on
Commit
c061cec
·
verified ·
1 Parent(s): 7ea24de

Create modules/data_loader.py

Browse files
Files changed (1) hide show
  1. modules/data_loader.py +17 -0
modules/data_loader.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # modules/data_loader.py
2
+
3
+ import os
4
+ from config.settings import DATA_PATH
5
+
6
+ def load_texts(file_path: str = DATA_PATH) -> list:
7
+ """
8
+ Load text data from a .txt file.
9
+ Each line in the file is treated as a separate text entry.
10
+ """
11
+ if not os.path.exists(file_path):
12
+ raise FileNotFoundError(f"Data file not found: {file_path}")
13
+
14
+ with open(file_path, "r", encoding="utf-8") as f:
15
+ texts = [line.strip() for line in f.readlines() if line.strip()]
16
+
17
+ return texts