Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -5,11 +5,11 @@ from appStore.prep_utils import create_documents, get_client
|
|
5 |
from appStore.embed import hybrid_embed_chunks
|
6 |
from appStore.search import hybrid_search
|
7 |
from appStore.region_utils import load_region_data, get_country_name
|
|
|
8 |
from torch import cuda
|
9 |
import json
|
10 |
from datetime import datetime
|
11 |
|
12 |
-
|
13 |
# get the device to be used eithe gpu or cpu
|
14 |
device = 'cuda' if cuda.is_available() else 'cpu'
|
15 |
|
@@ -133,6 +133,12 @@ if button:
|
|
133 |
remainder_text = " ".join(words[preview_word_count:])
|
134 |
# Always display the preview_text
|
135 |
st.write(preview_text + ("..." if remainder_text else ""))
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
# ------- Additional info below the text -------
|
137 |
metadata = res.payload.get('metadata', {})
|
138 |
countries = metadata.get('countries', "[]")
|
@@ -178,6 +184,13 @@ if button:
|
|
178 |
remainder_text = " ".join(words[preview_word_count:])
|
179 |
# Always display the preview_text
|
180 |
st.write(preview_text + ("..." if remainder_text else ""))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
# Additional text below the content
|
182 |
metadata = res.payload.get('metadata', {})
|
183 |
countries = metadata.get('countries', "[]")
|
|
|
5 |
from appStore.embed import hybrid_embed_chunks
|
6 |
from appStore.search import hybrid_search
|
7 |
from appStore.region_utils import load_region_data, get_country_name
|
8 |
+
from appStore.tfidf_extraction import extract_top_keywords
|
9 |
from torch import cuda
|
10 |
import json
|
11 |
from datetime import datetime
|
12 |
|
|
|
13 |
# get the device to be used eithe gpu or cpu
|
14 |
device = 'cuda' if cuda.is_available() else 'cpu'
|
15 |
|
|
|
133 |
remainder_text = " ".join(words[preview_word_count:])
|
134 |
# Always display the preview_text
|
135 |
st.write(preview_text + ("..." if remainder_text else ""))
|
136 |
+
# ------ Extract top 5 keywords and display ------
|
137 |
+
top_keywords = extract_top_keywords(full_text, top_n=5)
|
138 |
+
# Join them with " 路 " and make them italic
|
139 |
+
if top_keywords:
|
140 |
+
st.write("")
|
141 |
+
st.markdown(f"_{' 路 '.join(top_keywords)}_") # e.g. _keyword1 路 keyword2 路 keyword3_
|
142 |
# ------- Additional info below the text -------
|
143 |
metadata = res.payload.get('metadata', {})
|
144 |
countries = metadata.get('countries', "[]")
|
|
|
184 |
remainder_text = " ".join(words[preview_word_count:])
|
185 |
# Always display the preview_text
|
186 |
st.write(preview_text + ("..." if remainder_text else ""))
|
187 |
+
# ------ Extract top 5 keywords and display ------
|
188 |
+
top_keywords = extract_top_keywords(full_text, top_n=5)
|
189 |
+
# Join them with " 路 " and make them italic
|
190 |
+
if top_keywords:
|
191 |
+
st.write("") # line break
|
192 |
+
st.markdown(f"_{' 路 '.join(top_keywords)}_")
|
193 |
+
|
194 |
# Additional text below the content
|
195 |
metadata = res.payload.get('metadata', {})
|
196 |
countries = metadata.get('countries', "[]")
|