Spaces:
Sleeping
Sleeping
Commit ·
dd2d8f6
1
Parent(s): 0c16b32
Refactor: Move scraping logic to data_ingestion folder
Browse files
README.md
CHANGED
|
@@ -46,10 +46,10 @@ graph TD
|
|
| 46 |
|
| 47 |
### Components
|
| 48 |
|
| 49 |
-
1. **Data Ingestion (`scraper.py`)**:
|
| 50 |
* Fetches 8 specific road-test articles.
|
| 51 |
* Parses HTML to extract clean text (Title, Subtitle, Body).
|
| 52 |
-
* Saves to `scraped_data.json`.
|
| 53 |
|
| 54 |
2. **RAG Engine (`rag_engine.py`)**:
|
| 55 |
* **Encoder**: `sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2` for creating vector embeddings of text chunks.
|
|
|
|
| 46 |
|
| 47 |
### Components
|
| 48 |
|
| 49 |
+
1. **Data Ingestion (`data_ingestion/scraper.py`)**:
|
| 50 |
* Fetches 8 specific road-test articles.
|
| 51 |
* Parses HTML to extract clean text (Title, Subtitle, Body).
|
| 52 |
+
* Saves to `data_ingestion/scraped_data.json`.
|
| 53 |
|
| 54 |
2. **RAG Engine (`rag_engine.py`)**:
|
| 55 |
* **Encoder**: `sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2` for creating vector embeddings of text chunks.
|
__pycache__/rag_engine.cpython-311.pyc
ADDED
|
Binary file (6.86 kB). View file
|
|
|
data_ingestion/__init__.py
ADDED
|
File without changes
|
scraped_data.json → data_ingestion/scraped_data.json
RENAMED
|
File without changes
|
scraper.py → data_ingestion/scraper.py
RENAMED
|
@@ -105,7 +105,9 @@ def main():
|
|
| 105 |
|
| 106 |
if __name__ == "__main__":
|
| 107 |
import json
|
|
|
|
| 108 |
data = main()
|
| 109 |
-
|
|
|
|
| 110 |
json.dump(data, f, ensure_ascii=False, indent=2)
|
| 111 |
-
print("Saved to
|
|
|
|
| 105 |
|
| 106 |
if __name__ == "__main__":
|
| 107 |
import json
|
| 108 |
+
import os
|
| 109 |
data = main()
|
| 110 |
+
output_path = os.path.join(os.path.dirname(__file__), "scraped_data.json")
|
| 111 |
+
with open(output_path, "w", encoding='utf-8') as f:
|
| 112 |
json.dump(data, f, ensure_ascii=False, indent=2)
|
| 113 |
+
print(f"Saved to {output_path}")
|
rag_engine.py
CHANGED
|
@@ -5,7 +5,7 @@ import google.generativeai as genai
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
class RAGEngine:
|
| 8 |
-
def __init__(self, data_path="scraped_data.json"):
|
| 9 |
print("Initializing RAG Engine...")
|
| 10 |
self.data_path = data_path
|
| 11 |
self.encoder = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2')
|
|
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
class RAGEngine:
|
| 8 |
+
def __init__(self, data_path="data_ingestion/scraped_data.json"):
|
| 9 |
print("Initializing RAG Engine...")
|
| 10 |
self.data_path = data_path
|
| 11 |
self.encoder = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2')
|