ez326 commited on
Commit
44aace1
·
verified ·
1 Parent(s): 225f143

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -13
app.py CHANGED
@@ -66,10 +66,9 @@ css = """
66
  """
67
  st.markdown(css, unsafe_allow_html=True)
68
 
69
- # Allow the user to choose whether to rate a movie or a sitcom.
70
- rating_type = st.radio("Select Rating Type", ["Movie", "Sitcom"], index=0)
71
 
72
- # Define criteria based on the rating type.
73
  if rating_type == "Movie":
74
  criteria = {
75
  "Writing": [
@@ -115,8 +114,9 @@ if rating_type == "Movie":
115
  {"name": "Emotional Impact", "description": "Strength of connection, intensity of response."}
116
  ]
117
  }
118
- scoring_weights = None # Use flat averaging for movies.
119
- else:
 
120
  criteria = {
121
  "Writing & Humor": [
122
  {"name": "Dialogue & Humor", "description": "Witty exchanges, comedic timing, and joke quality."},
@@ -140,7 +140,6 @@ else:
140
  {"name": "Rewatchability", "description": "Longevity of appeal and repeat enjoyment."}
141
  ]
142
  }
143
- # Define group weights for sitcoms (weights sum to 1)
144
  scoring_weights = {
145
  "Writing & Humor": 0.3,
146
  "Performance & Chemistry": 0.3,
@@ -149,9 +148,34 @@ else:
149
  "Audience Engagement": 0.1
150
  }
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  def calculate_score(criteria, weights=None):
153
  if weights is None:
154
- # For movies: flat average of all ratings.
155
  ratings = []
156
  for group, subcriteria in criteria.items():
157
  for idx in range(len(subcriteria)):
@@ -164,10 +188,9 @@ def calculate_score(criteria, weights=None):
164
  if not valid:
165
  return "Please rate at least one criterion."
166
  avg = sum(valid) / len(valid)
167
- final_score = (avg + 1) * 5 # Maps average in [-1, 1] to [0, 10]
168
  return f"Final Score: {final_score:.2f} / 10"
169
  else:
170
- # For sitcoms: compute a weighted average by criteria group.
171
  overall = 0
172
  for group, subcriteria in criteria.items():
173
  group_ratings = []
@@ -186,10 +209,13 @@ def calculate_score(criteria, weights=None):
186
  final_score = (overall + 1) * 5
187
  return f"Final Score: {final_score:.2f} / 10"
188
 
189
- header_text = "Movie Rating System" if rating_type == "Movie" else "Sitcom Rating System"
 
 
 
 
190
  st.markdown(f"<h1 class='app-header'>{header_text}</h1>", unsafe_allow_html=True)
191
 
192
- # Loop over each criterion and display the checkbox, text, and three horizontal buttons for rating.
193
  for group, subcriteria in criteria.items():
194
  st.markdown(f"<div class='category-header'>{group}</div>", unsafe_allow_html=True)
195
  for idx, crit in enumerate(subcriteria):
@@ -198,7 +224,6 @@ for group, subcriteria in criteria.items():
198
  st.session_state[f"rating_{key_prefix}"] = None
199
 
200
  with st.container():
201
- # Two columns: checkbox on the left and content on the right.
202
  cols = st.columns([0.5, 7])
203
  checkbox_col = cols[0]
204
  content_col = cols[1]
@@ -211,7 +236,6 @@ for group, subcriteria in criteria.items():
211
  )
212
  content_col.markdown(combined, unsafe_allow_html=True)
213
 
214
- # Wrap the buttons in a container for styling.
215
  content_col.markdown('<div class="binary-btns-container">', unsafe_allow_html=True)
216
  btn_cols = content_col.columns(3, gap="small")
217
  if btn_cols[0].button("👎", key=f"btn_down_{key_prefix}"):
 
66
  """
67
  st.markdown(css, unsafe_allow_html=True)
68
 
69
+ # Let the user select which type of show they are rating.
70
+ rating_type = st.radio("Select Rating Type", ["Movie", "Sitcom", "Reality TV"], index=0)
71
 
 
72
  if rating_type == "Movie":
73
  criteria = {
74
  "Writing": [
 
114
  {"name": "Emotional Impact", "description": "Strength of connection, intensity of response."}
115
  ]
116
  }
117
+ scoring_weights = None # Flat averaging for movies.
118
+
119
+ elif rating_type == "Sitcom":
120
  criteria = {
121
  "Writing & Humor": [
122
  {"name": "Dialogue & Humor", "description": "Witty exchanges, comedic timing, and joke quality."},
 
140
  {"name": "Rewatchability", "description": "Longevity of appeal and repeat enjoyment."}
141
  ]
142
  }
 
143
  scoring_weights = {
144
  "Writing & Humor": 0.3,
145
  "Performance & Chemistry": 0.3,
 
148
  "Audience Engagement": 0.1
149
  }
150
 
151
+ else: # Reality TV (e.g., Survivor)
152
+ criteria = {
153
+ "Social & Strategy": [
154
+ {"name": "Alliance & Social Dynamics", "description": "Quality of contestant interactions, alliances, and social gameplay."},
155
+ {"name": "Strategy & Decision Making", "description": "Smart, tactical decisions and risk management."}
156
+ ],
157
+ "Challenges & Endurance": [
158
+ {"name": "Physical Performance", "description": "Effectiveness and endurance in physical challenges."},
159
+ {"name": "Mental Agility", "description": "Problem-solving skills and performance in mental challenges."}
160
+ ],
161
+ "Production & Narrative": [
162
+ {"name": "Editing & Storytelling", "description": "Crafting an engaging narrative from real events."},
163
+ {"name": "Cinematography & Environment", "description": "Quality of visuals and effective use of natural settings."}
164
+ ],
165
+ "Host & Engagement": [
166
+ {"name": "Host Performance", "description": "Charisma, control, and the ability to engage contestants and audience."},
167
+ {"name": "Overall Entertainment", "description": "The show's excitement, drama, and rewatchability."}
168
+ ]
169
+ }
170
+ scoring_weights = {
171
+ "Social & Strategy": 0.3,
172
+ "Challenges & Endurance": 0.3,
173
+ "Production & Narrative": 0.2,
174
+ "Host & Engagement": 0.2
175
+ }
176
+
177
  def calculate_score(criteria, weights=None):
178
  if weights is None:
 
179
  ratings = []
180
  for group, subcriteria in criteria.items():
181
  for idx in range(len(subcriteria)):
 
188
  if not valid:
189
  return "Please rate at least one criterion."
190
  avg = sum(valid) / len(valid)
191
+ final_score = (avg + 1) * 5 # Map from [-1, 1] to [0, 10]
192
  return f"Final Score: {final_score:.2f} / 10"
193
  else:
 
194
  overall = 0
195
  for group, subcriteria in criteria.items():
196
  group_ratings = []
 
209
  final_score = (overall + 1) * 5
210
  return f"Final Score: {final_score:.2f} / 10"
211
 
212
+ header_text = (
213
+ "Movie Rating System" if rating_type == "Movie"
214
+ else "Sitcom Rating System" if rating_type == "Sitcom"
215
+ else "Reality TV Rating System"
216
+ )
217
  st.markdown(f"<h1 class='app-header'>{header_text}</h1>", unsafe_allow_html=True)
218
 
 
219
  for group, subcriteria in criteria.items():
220
  st.markdown(f"<div class='category-header'>{group}</div>", unsafe_allow_html=True)
221
  for idx, crit in enumerate(subcriteria):
 
224
  st.session_state[f"rating_{key_prefix}"] = None
225
 
226
  with st.container():
 
227
  cols = st.columns([0.5, 7])
228
  checkbox_col = cols[0]
229
  content_col = cols[1]
 
236
  )
237
  content_col.markdown(combined, unsafe_allow_html=True)
238
 
 
239
  content_col.markdown('<div class="binary-btns-container">', unsafe_allow_html=True)
240
  btn_cols = content_col.columns(3, gap="small")
241
  if btn_cols[0].button("👎", key=f"btn_down_{key_prefix}"):