Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -198,24 +198,24 @@ def get_article_recommendations(user_input):
|
|
| 198 |
|
| 199 |
def get_links(user_input):
|
| 200 |
recommendations = get_article_recommendations(user_input)
|
| 201 |
-
print(recommendations)
|
| 202 |
links = []
|
| 203 |
for article in recommendations:
|
| 204 |
cosine_similarity, article_id, journal_id = article
|
| 205 |
-
|
| 206 |
-
journal_main['article_df'][journal_id].iloc[article_id, 0],
|
| 207 |
-
journal_main['article_df'][journal_id].iloc[article_id, 1],
|
| 208 |
-
article_id,
|
| 209 |
-
journal_id
|
| 210 |
-
|
| 211 |
-
|
| 212 |
return links
|
| 213 |
|
| 214 |
|
|
|
|
| 215 |
gradio_interface = gradio.Interface(
|
| 216 |
fn=get_links,
|
| 217 |
inputs="text",
|
| 218 |
-
outputs=gradio.outputs.
|
| 219 |
examples=[
|
| 220 |
["Jill"],
|
| 221 |
["Sam"]
|
|
|
|
| 198 |
|
| 199 |
def get_links(user_input):
|
| 200 |
recommendations = get_article_recommendations(user_input)
|
|
|
|
| 201 |
links = []
|
| 202 |
for article in recommendations:
|
| 203 |
cosine_similarity, article_id, journal_id = article
|
| 204 |
+
link = {
|
| 205 |
+
"title": journal_main['article_df'][journal_id].iloc[article_id, 0],
|
| 206 |
+
"url": journal_main['article_df'][journal_id].iloc[article_id, 1],
|
| 207 |
+
"article_id": article_id,
|
| 208 |
+
"journal_id": journal_id
|
| 209 |
+
}
|
| 210 |
+
links.append(link)
|
| 211 |
return links
|
| 212 |
|
| 213 |
|
| 214 |
+
|
| 215 |
gradio_interface = gradio.Interface(
|
| 216 |
fn=get_links,
|
| 217 |
inputs="text",
|
| 218 |
+
outputs=gradio.outputs.JSON(),
|
| 219 |
examples=[
|
| 220 |
["Jill"],
|
| 221 |
["Sam"]
|