barunsaha commited on
Commit
732e5fa
·
unverified ·
2 Parent(s): 3375723 e481e40

Merge pull request #26 from barun-saha/visual

Browse files
helpers/image_search.py CHANGED
@@ -12,7 +12,7 @@ import requests
12
 
13
 
14
  REQUEST_TIMEOUT = 12
15
- MAX_PHOTOS = 2
16
 
17
 
18
  # Only show warnings
 
12
 
13
 
14
  REQUEST_TIMEOUT = 12
15
+ MAX_PHOTOS = 3
16
 
17
 
18
  # Only show warnings
helpers/pptx_helper.py CHANGED
@@ -34,8 +34,8 @@ INCHES_0_4 = pptx.util.Inches(0.4)
34
  INCHES_0_3 = pptx.util.Inches(0.3)
35
 
36
  STEP_BY_STEP_PROCESS_MARKER = '>> '
37
- IMAGE_DISPLAY_PROBABILITY = 0.3
38
- FOREGROUND_IMAGE_PROBABILITY = 0.75
39
  SLIDE_NUMBER_REGEX = re.compile(r"^slide[ ]+\d+:", re.IGNORECASE)
40
 
41
 
@@ -92,8 +92,6 @@ def generate_powerpoint_presentation(
92
 
93
  # Add content in a loop
94
  for a_slide in parsed_data['slides']:
95
- # The loop has a bug:
96
- # if any of this functions fail (i.e., returns False), an empty slide would still exist
97
  is_processing_done = _handle_double_col_layout(
98
  presentation=presentation,
99
  slide_json=a_slide,
@@ -623,6 +621,11 @@ def _handle_step_by_step_process(
623
  ):
624
  return False
625
 
 
 
 
 
 
626
  bullet_slide_layout = presentation.slide_layouts[1]
627
  slide = presentation.slides.add_slide(bullet_slide_layout)
628
  shapes = slide.shapes
@@ -665,10 +668,6 @@ def _handle_step_by_step_process(
665
  shape.text = step.removeprefix(STEP_BY_STEP_PROCESS_MARKER)
666
  top += height + INCHES_0_3
667
  left += INCHES_0_5
668
- else:
669
- # Two steps -- probably not a process
670
- # More than 5--6 steps -- would likely cause a visual clutter
671
- return False
672
 
673
  return True
674
 
 
34
  INCHES_0_3 = pptx.util.Inches(0.3)
35
 
36
  STEP_BY_STEP_PROCESS_MARKER = '>> '
37
+ IMAGE_DISPLAY_PROBABILITY = 1 / 3.0
38
+ FOREGROUND_IMAGE_PROBABILITY = 0.8
39
  SLIDE_NUMBER_REGEX = re.compile(r"^slide[ ]+\d+:", re.IGNORECASE)
40
 
41
 
 
92
 
93
  # Add content in a loop
94
  for a_slide in parsed_data['slides']:
 
 
95
  is_processing_done = _handle_double_col_layout(
96
  presentation=presentation,
97
  slide_json=a_slide,
 
621
  ):
622
  return False
623
 
624
+ if n_steps < 3 or n_steps > 6:
625
+ # Two steps -- probably not a process
626
+ # More than 5--6 steps -- would likely cause a visual clutter
627
+ return False
628
+
629
  bullet_slide_layout = presentation.slide_layouts[1]
630
  slide = presentation.slides.add_slide(bullet_slide_layout)
631
  shapes = slide.shapes
 
668
  shape.text = step.removeprefix(STEP_BY_STEP_PROCESS_MARKER)
669
  top += height + INCHES_0_3
670
  left += INCHES_0_5
 
 
 
 
671
 
672
  return True
673