Update app.py
Browse files
app.py
CHANGED
|
@@ -5,11 +5,10 @@ import torch
|
|
| 5 |
from itertools import chain
|
| 6 |
|
| 7 |
raw_dataset = load_dataset("asuender/motivational-quotes", "quotes_extended", split="train")
|
| 8 |
-
dataset = list(raw_dataset)
|
| 9 |
|
| 10 |
-
quotes = [item["quote"] for item in
|
| 11 |
-
authors = [item["author"] for item in
|
| 12 |
-
tags_list = [item["tags"] for item in
|
| 13 |
|
| 14 |
all_tags = list(set(chain.from_iterable(tags_list)))
|
| 15 |
all_tags.sort()
|
|
@@ -35,7 +34,7 @@ def recommend_quote(mood_input, selected_tag):
|
|
| 35 |
|
| 36 |
result = ""
|
| 37 |
for i in top_k.indices[0]:
|
| 38 |
-
result += f"
|
| 39 |
|
| 40 |
return result.strip()
|
| 41 |
|
|
@@ -46,7 +45,7 @@ iface = gr.Interface(
|
|
| 46 |
gr.Dropdown(choices=all_tags, label="Select a category")
|
| 47 |
],
|
| 48 |
outputs="text",
|
| 49 |
-
title="MoodMatch
|
| 50 |
description="Get inspiring quotes based on your mood and selected category."
|
| 51 |
)
|
| 52 |
|
|
|
|
| 5 |
from itertools import chain
|
| 6 |
|
| 7 |
raw_dataset = load_dataset("asuender/motivational-quotes", "quotes_extended", split="train")
|
|
|
|
| 8 |
|
| 9 |
+
quotes = [item["quote"] for item in raw_dataset]
|
| 10 |
+
authors = [item["author"] for item in raw_dataset]
|
| 11 |
+
tags_list = [item["tags"] for item in raw_dataset]
|
| 12 |
|
| 13 |
all_tags = list(set(chain.from_iterable(tags_list)))
|
| 14 |
all_tags.sort()
|
|
|
|
| 34 |
|
| 35 |
result = ""
|
| 36 |
for i in top_k.indices[0]:
|
| 37 |
+
result += f"{f_quotes[i]}\n– {f_authors[i]}\n\n"
|
| 38 |
|
| 39 |
return result.strip()
|
| 40 |
|
|
|
|
| 45 |
gr.Dropdown(choices=all_tags, label="Select a category")
|
| 46 |
],
|
| 47 |
outputs="text",
|
| 48 |
+
title="MoodMatch – AI Quote Recommender",
|
| 49 |
description="Get inspiring quotes based on your mood and selected category."
|
| 50 |
)
|
| 51 |
|