yashraizada commited on
Commit
b087c4c
1 Parent(s): b716d57

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +103 -0
app.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ from data import *
4
+ from utils import *
5
+ from images import *
6
+
7
+ # Setting Page Config
8
+ set_page_config()
9
+
10
+ # Load datasets
11
+ business_dataset = get_business_data()
12
+ top_reviews_dataset = get_top_reviews_per_business()
13
+ user_dataset = get_users_data()
14
+ business_names = get_business_names(business_dataset)
15
+
16
+ # Define Search Buttons
17
+ _, select_business_col, select_location_col, _ = st.columns([1, 1, 1, 1])
18
+
19
+ with select_business_col:
20
+ selected_business = st.selectbox(label="Select a business", options=business_names, placeholder="Search for a business...", index=None, label_visibility="hidden")
21
+
22
+ with select_location_col:
23
+ if selected_business:
24
+ options = get_business_locations(business_dataset, selected_business)
25
+ index_value = 0
26
+ else:
27
+ options = ["Select a business to see locations"]
28
+ index_value = None
29
+
30
+ selected_location = st.selectbox(label="Select a location", options=options, placeholder="in United States of America", index=index_value, label_visibility="hidden")
31
+
32
+ # Adding space after the search buttons
33
+ draw_space()
34
+
35
+ # Define columns for business info and review insights
36
+ business_info_col, _, review_insights_col = st.columns([0.6, 0.1, 0.3])
37
+
38
+ with business_info_col:
39
+ # Define columns for business image, business description, and business review summary
40
+ business_image_col, _, business_description_col, _, business_review_summary_col = st.columns([0.2, 0.05, 0.4, 0.05, 0.3])
41
+
42
+ if selected_business:
43
+ # Get a dictonary with all information for the selected business
44
+ selected_business_dict = get_business_info(business_dataset, selected_business, selected_location)
45
+
46
+ with st.container():
47
+ with business_image_col:
48
+ st.image(get_business_logo_url(selected_business_dict['name'].lower()))
49
+
50
+ with business_description_col:
51
+ st.subheader(selected_business_dict['name'])
52
+ st.markdown(f'''{selected_business_dict['address']}
53
+ {selected_business_dict['price_range']}  •  {selected_business_dict['wifi']} Wifi  •  {selected_business_dict['categories']}
54
+ ''')
55
+
56
+ with business_review_summary_col:
57
+ st.subheader("Overall Rating")
58
+ st.image(get_business_stars_url(selected_business_dict['stars']), width=150)
59
+ st.markdown(f"##### {selected_business_dict['review_count']} reviews")
60
+
61
+ draw_space()
62
+ draw_line()
63
+
64
+ selected_business_reviews = get_selected_business_reviews(top_reviews_dataset, selected_business_dict['id'])
65
+
66
+ st.subheader('Recommended Reviews')
67
+ draw_space()
68
+
69
+ for i in range(5):
70
+ # Define columns for user avatar and user info
71
+ user_avatar_col, user_info_col = st.columns([0.1, 0.9])
72
+
73
+ # Load dependencies
74
+ review_dict = selected_business_reviews.iloc[i, :]
75
+
76
+ user_id = review_dict['user_id']
77
+ user_info_dict = get_user_info(user_dataset, user_id)
78
+ user_avatar_url = get_user_avatar_url(user_id)
79
+
80
+ with st.container():
81
+ with user_avatar_col:
82
+ st.image(user_avatar_url)
83
+
84
+ with user_info_col:
85
+ st.markdown(f"###### {user_info_dict['name']}")
86
+ st.markdown(f"{user_info_dict['review_count']} reviews  •  {user_info_dict['fans']} fans  •  {user_info_dict['friends_count']} friends  •  {user_info_dict['years_on_yelp']} years on Yelp  •  Elite for {user_info_dict['elite_years_count']} years")
87
+
88
+ with st.container():
89
+ review_rating_col, review_date_col = st.columns([0.12, 0.88])
90
+
91
+ with review_rating_col:
92
+ st.image(get_business_stars_url(review_dict['stars']))
93
+
94
+ with review_date_col:
95
+ st.markdown(review_dict['date'])
96
+
97
+ with st.container():
98
+ st.markdown(review_dict['text'])
99
+
100
+ draw_space()
101
+
102
+ with review_insights_col:
103
+ pass