Spaces:
Sleeping
Sleeping
Changed the Def suggested
Browse files
app.py
CHANGED
|
@@ -10,9 +10,9 @@ clothing_df = pd.read_csv("clothes.csv")
|
|
| 10 |
|
| 11 |
# --- Simple filtering function ---
|
| 12 |
def get_suggestions(query):
|
| 13 |
-
results = clothing_df
|
| 14 |
-
|
| 15 |
q = query.lower()
|
|
|
|
| 16 |
# Weather-based filtering
|
| 17 |
if "rain" in q:
|
| 18 |
results = results[results['weather'].str.contains("rain", case=False, na=False)]
|
|
@@ -24,18 +24,23 @@ def get_suggestions(query):
|
|
| 24 |
results = results[results['weather'].str.contains("snow", case=False, na=False)]
|
| 25 |
|
| 26 |
# Formality-based filtering
|
| 27 |
-
|
| 28 |
results = results[results['formality'].str.contains("formal", case=False, na=False)]
|
| 29 |
elif "casual" in q:
|
| 30 |
results = results[results['formality'].str.contains("casual", case=False, na=False)]
|
| 31 |
|
| 32 |
-
# If no
|
| 33 |
if len(results) == 0:
|
| 34 |
-
results = clothing_df.
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
|
|
|
|
|
|
| 39 |
|
| 40 |
# --- Chatbot + image output ---
|
| 41 |
def respond(message, history):
|
|
|
|
| 10 |
|
| 11 |
# --- Simple filtering function ---
|
| 12 |
def get_suggestions(query):
|
| 13 |
+
results = clothing_df.copy()
|
|
|
|
| 14 |
q = query.lower()
|
| 15 |
+
|
| 16 |
# Weather-based filtering
|
| 17 |
if "rain" in q:
|
| 18 |
results = results[results['weather'].str.contains("rain", case=False, na=False)]
|
|
|
|
| 24 |
results = results[results['weather'].str.contains("snow", case=False, na=False)]
|
| 25 |
|
| 26 |
# Formality-based filtering
|
| 27 |
+
if "formal" in q or "office" in q:
|
| 28 |
results = results[results['formality'].str.contains("formal", case=False, na=False)]
|
| 29 |
elif "casual" in q:
|
| 30 |
results = results[results['formality'].str.contains("casual", case=False, na=False)]
|
| 31 |
|
| 32 |
+
# If no results after filtering, fallback to full database
|
| 33 |
if len(results) == 0:
|
| 34 |
+
results = clothing_df.copy()
|
| 35 |
+
|
| 36 |
+
# --- Pick one item per category ---
|
| 37 |
+
outfit = []
|
| 38 |
+
for category, group in results.groupby('category'):
|
| 39 |
+
outfit.append(group.sample(1)) # take one random item per category
|
| 40 |
|
| 41 |
+
# Combine into single DataFrame
|
| 42 |
+
final_selection = pd.concat(outfit)
|
| 43 |
+
return final_selection
|
| 44 |
|
| 45 |
# --- Chatbot + image output ---
|
| 46 |
def respond(message, history):
|