barunsaha commited on
Commit
2c68fcd
1 Parent(s): 294b6dd

Address scenario where a step does not begin with the designated marker

Browse files
Files changed (1) hide show
  1. helpers/pptx_helper.py +21 -7
helpers/pptx_helper.py CHANGED
@@ -97,11 +97,6 @@ def generate_powerpoint_presentation(
97
  subtitle.text = 'by Myself and SlideDeck AI :)'
98
  all_headers = [title.text, ]
99
 
100
- # background = slide.background
101
- # background.fill.solid()
102
- # background.fill.fore_color.rgb = RGBColor.from_string('C0C0C0') # Silver
103
- # title.text_frame.paragraphs[0].font.color.rgb = RGBColor(0, 0, 128) # Navy blue
104
-
105
  # Add contents in a loop
106
  for a_slide in parsed_data['slides']:
107
  bullet_slide_layout = presentation.slide_layouts[1]
@@ -202,17 +197,36 @@ def _handle_step_by_step_process(
202
  if 'bullet_points' in slide_json and slide_json['bullet_points']:
203
  steps = slide_json['bullet_points']
204
 
 
 
 
205
  # Ensure that it is a single list of strings without any sub-list
206
  for step in steps:
207
  if not isinstance(step, str):
208
  return False
209
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  if not step.startswith(STEP_BY_STEP_PROCESS_MARKER):
211
- return False
 
 
 
212
 
213
  shapes = slide.shapes
214
  shapes.title.text = remove_slide_number_from_heading(slide_json['heading'])
215
- n_steps = len(steps)
216
 
217
  if 3 <= n_steps <= 4:
218
  # Horizontal display
 
97
  subtitle.text = 'by Myself and SlideDeck AI :)'
98
  all_headers = [title.text, ]
99
 
 
 
 
 
 
100
  # Add contents in a loop
101
  for a_slide in parsed_data['slides']:
102
  bullet_slide_layout = presentation.slide_layouts[1]
 
197
  if 'bullet_points' in slide_json and slide_json['bullet_points']:
198
  steps = slide_json['bullet_points']
199
 
200
+ no_marker_count = 0.0
201
+ n_steps = len(steps)
202
+
203
  # Ensure that it is a single list of strings without any sub-list
204
  for step in steps:
205
  if not isinstance(step, str):
206
  return False
207
 
208
+ # In some cases, one or two steps may not begin with >>, e.g.:
209
+ # {
210
+ # "heading": "Step-by-Step Process: Creating a Legacy",
211
+ # "bullet_points": [
212
+ # "Identify your unique talents and passions",
213
+ # ">> Develop your skills and knowledge",
214
+ # ">> Create meaningful work",
215
+ # ">> Share your work with the world",
216
+ # ">> Continuously learn and adapt"
217
+ # ],
218
+ # "key_message": ""
219
+ # },
220
+ #
221
+ # Use a threshold, e.g., at most 20%
222
  if not step.startswith(STEP_BY_STEP_PROCESS_MARKER):
223
+ no_marker_count += 1
224
+
225
+ if no_marker_count / n_steps > 0.2:
226
+ return False
227
 
228
  shapes = slide.shapes
229
  shapes.title.text = remove_slide_number_from_heading(slide_json['heading'])
 
230
 
231
  if 3 <= n_steps <= 4:
232
  # Horizontal display