Update app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,17 @@ model = SentenceTransformer('all-MiniLM-L6-v2')
|
|
22 |
#]
|
23 |
|
24 |
queries = pd.read_excel("egu_session_descriptions.xlsx").Description
|
25 |
-
titles = pd.read_excel("egu_session_descriptions.xlsx").Title
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
# Precompute embeddings for the queries
|
27 |
query_embeddings = model.encode(queries)
|
28 |
|
@@ -64,7 +74,17 @@ def server(input, output, session):
|
|
64 |
top_indices = np.argsort(similarities)[-5:][::-1]
|
65 |
|
66 |
# Prepare the results to display
|
67 |
-
result_boxes = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
return result_boxes
|
69 |
return ui.div("Please enter text and press the button.")
|
70 |
|
|
|
22 |
#]
|
23 |
|
24 |
queries = pd.read_excel("egu_session_descriptions.xlsx").Description
|
25 |
+
titles = pd.read_excel("egu_session_descriptions.xlsx").Title
|
26 |
+
ids = pd.read_excel("egu_session_descriptions.xlsx").ID
|
27 |
+
|
28 |
+
|
29 |
+
prefix = "https://meetingorganizer.copernicus.org/EGU25/session/"
|
30 |
+
|
31 |
+
# Create a new list with the URL prefix added to each number
|
32 |
+
urls = [f"{prefix}{num}" for num in ids]
|
33 |
+
|
34 |
+
|
35 |
+
# The column to display as results
|
36 |
# Precompute embeddings for the queries
|
37 |
query_embeddings = model.encode(queries)
|
38 |
|
|
|
74 |
top_indices = np.argsort(similarities)[-5:][::-1]
|
75 |
|
76 |
# Prepare the results to display
|
77 |
+
result_boxes = [
|
78 |
+
ui.a(
|
79 |
+
ui.div(
|
80 |
+
titles[idx],
|
81 |
+
style="padding: 10px; margin: 5px; border-radius: 5px; color: white; font-weight: bold; background-color: #4682B4;"
|
82 |
+
),
|
83 |
+
href=urls[idx], target="_blank" # Open in a new tab
|
84 |
+
)
|
85 |
+
for idx in top_indices
|
86 |
+
]
|
87 |
+
#result_boxes = [ui.div(titles[idx], style="padding: 10px; margin: 5px; border-radius: 5px; color: white; font-weight: bold; background-color: #4682B4;") for idx in top_indices]
|
88 |
return result_boxes
|
89 |
return ui.div("Please enter text and press the button.")
|
90 |
|