Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -70,7 +70,7 @@ def prepare_and_recommend(df, user_description):
|
|
| 70 |
tfidf_matrix = tfidf.fit_transform(df['deskripsi'].astype(str).tolist() + [user_description])
|
| 71 |
similarity = cosine_similarity(tfidf_matrix[-1], tfidf_matrix[:-1]).flatten()
|
| 72 |
df['similarity'] = similarity
|
| 73 |
-
return df.sort_values(by='similarity', ascending=False).head(
|
| 74 |
|
| 75 |
def sort_by_nearest_location(df, user_lat, user_lon):
|
| 76 |
df['distance_km'] = df.apply(
|
|
@@ -96,6 +96,8 @@ def wisata_rekomendasi(deskripsi, lokasi):
|
|
| 96 |
|
| 97 |
top_place = prepare_and_recommend(df.copy(), user_description_joined)
|
| 98 |
sorted_place = sort_by_nearest_location(top_place, lat, lon)
|
|
|
|
|
|
|
| 99 |
|
| 100 |
return f"Kata kunci: {', '.join(keywords)}", sorted_place[["id","nama","alamat", "distance_km", "deskripsi","harga","rating","total_ulasan","gambar"]]
|
| 101 |
|
|
|
|
| 70 |
tfidf_matrix = tfidf.fit_transform(df['deskripsi'].astype(str).tolist() + [user_description])
|
| 71 |
similarity = cosine_similarity(tfidf_matrix[-1], tfidf_matrix[:-1]).flatten()
|
| 72 |
df['similarity'] = similarity
|
| 73 |
+
return df.sort_values(by='similarity', ascending=False).head(10)
|
| 74 |
|
| 75 |
def sort_by_nearest_location(df, user_lat, user_lon):
|
| 76 |
df['distance_km'] = df.apply(
|
|
|
|
| 96 |
|
| 97 |
top_place = prepare_and_recommend(df.copy(), user_description_joined)
|
| 98 |
sorted_place = sort_by_nearest_location(top_place, lat, lon)
|
| 99 |
+
|
| 100 |
+
sorted_place = sorted_place[sorted_place["gambar"].apply(lambda x: isinstance(x, str) and x.startswith("https"))]
|
| 101 |
|
| 102 |
return f"Kata kunci: {', '.join(keywords)}", sorted_place[["id","nama","alamat", "distance_km", "deskripsi","harga","rating","total_ulasan","gambar"]]
|
| 103 |
|