Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1009,8 +1009,10 @@ def fetch_yelp_restaurants():
|
|
1009 |
|
1010 |
def star_rating(rating):
|
1011 |
full_stars = int(float(rating))
|
1012 |
-
half_star = 1 if float(rating) - full_stars >= 0.5 else 0
|
1013 |
-
|
|
|
|
|
1014 |
|
1015 |
response_text = ""
|
1016 |
|
@@ -1020,13 +1022,15 @@ def fetch_yelp_restaurants():
|
|
1020 |
reviews = result.get("reviews", "No reviews")
|
1021 |
phone = result.get("phone", "Not Available")
|
1022 |
snippet = result.get("snippet", "Not Available")
|
1023 |
-
|
|
|
1024 |
|
1025 |
if isinstance(snippet, list):
|
1026 |
snippet = " | ".join(snippet[:5]) # Limiting to top 5 snippets
|
1027 |
|
1028 |
# Format the output for each restaurant
|
1029 |
-
response_text += f"
|
|
|
1030 |
response_text += f"**Contact No:** {phone}\n"
|
1031 |
response_text += f"**Rating:** {star_rating(rating)} ({rating} stars, {reviews} reviews)\n"
|
1032 |
response_text += f"**Snippet:** {snippet}\n"
|
@@ -1037,6 +1041,7 @@ def fetch_yelp_restaurants():
|
|
1037 |
|
1038 |
|
1039 |
|
|
|
1040 |
with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
1041 |
with gr.Row():
|
1042 |
with gr.Column():
|
|
|
1009 |
|
1010 |
def star_rating(rating):
|
1011 |
full_stars = int(float(rating))
|
1012 |
+
half_star = 1 if (float(rating) - full_stars) >= 0.5 else 0
|
1013 |
+
empty_stars = 5 - full_stars - half_star
|
1014 |
+
stars = "★" * full_stars + "½" * half_star + "☆" * empty_stars
|
1015 |
+
return stars
|
1016 |
|
1017 |
response_text = ""
|
1018 |
|
|
|
1022 |
reviews = result.get("reviews", "No reviews")
|
1023 |
phone = result.get("phone", "Not Available")
|
1024 |
snippet = result.get("snippet", "Not Available")
|
1025 |
+
location = result.get("location", "Birmingham, AL")
|
1026 |
+
link = result.get("link", "#")
|
1027 |
|
1028 |
if isinstance(snippet, list):
|
1029 |
snippet = " | ".join(snippet[:5]) # Limiting to top 5 snippets
|
1030 |
|
1031 |
# Format the output for each restaurant
|
1032 |
+
response_text += f"**[{name}]({link})**\n" # Name in bold with clickable link
|
1033 |
+
response_text += f"*{location}*\n" # Location in italics
|
1034 |
response_text += f"**Contact No:** {phone}\n"
|
1035 |
response_text += f"**Rating:** {star_rating(rating)} ({rating} stars, {reviews} reviews)\n"
|
1036 |
response_text += f"**Snippet:** {snippet}\n"
|
|
|
1041 |
|
1042 |
|
1043 |
|
1044 |
+
|
1045 |
with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
1046 |
with gr.Row():
|
1047 |
with gr.Column():
|