Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,8 +16,9 @@ def load_files(path):
|
|
| 16 |
|
| 17 |
charities_text = load_files("charities.txt")
|
| 18 |
financial_advice_text = load_files("financial_advice.txt")
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
#
|
| 22 |
|
| 23 |
###
|
|
@@ -47,6 +48,9 @@ def preprocess_text(text):
|
|
| 47 |
|
| 48 |
cleaned_charities = preprocess_text(charities_text)
|
| 49 |
cleaned_finance = preprocess_text(financial_advice_text)
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
# Load the pre-trained embedding model that converts text to vectors
|
| 52 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
|
@@ -67,6 +71,9 @@ def create_embeddings(text_chunks):
|
|
| 67 |
|
| 68 |
charity_embeddings = create_embeddings(cleaned_charities)
|
| 69 |
finance_embeddings = create_embeddings(cleaned_finance)
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
###STEP 5
|
| 72 |
# Define a function to find the most relevant text chunks for a given query, chunk_embeddings, and text_chunks
|
|
|
|
| 16 |
|
| 17 |
charities_text = load_files("charities.txt")
|
| 18 |
financial_advice_text = load_files("financial_advice.txt")
|
| 19 |
+
un_text = load_files("un.txt")
|
| 20 |
+
investopedia_text = load_files("investopedia.txt")
|
| 21 |
+
cgf_text = load_files("cgf.txt")
|
| 22 |
#
|
| 23 |
|
| 24 |
###
|
|
|
|
| 48 |
|
| 49 |
cleaned_charities = preprocess_text(charities_text)
|
| 50 |
cleaned_finance = preprocess_text(financial_advice_text)
|
| 51 |
+
cleaned_un = preprocess_text(un_text)
|
| 52 |
+
cleaned_investopedia = preprocess_text(investopedia_text)
|
| 53 |
+
cleaned_cgf = preprocess_text(cgf_text)
|
| 54 |
|
| 55 |
# Load the pre-trained embedding model that converts text to vectors
|
| 56 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
|
|
|
| 71 |
|
| 72 |
charity_embeddings = create_embeddings(cleaned_charities)
|
| 73 |
finance_embeddings = create_embeddings(cleaned_finance)
|
| 74 |
+
un_embeddings = create_embeddings(cleaned_un)
|
| 75 |
+
investopedia_embeddings = create_embeddings(cleaned_investopedia)
|
| 76 |
+
cgf_embeddings = create_embeddings(cleaned_cgf)
|
| 77 |
|
| 78 |
###STEP 5
|
| 79 |
# Define a function to find the most relevant text chunks for a given query, chunk_embeddings, and text_chunks
|