MilanM commited on
Commit
f44aaef
·
verified ·
1 Parent(s): 6796622

Update pdf_generator.py

Browse files
Files changed (1) hide show
  1. pdf_generator.py +5 -2
pdf_generator.py CHANGED
@@ -155,11 +155,15 @@ def process_quantitative_criteria(answer, styles):
155
 
156
  def parse_quantitative_criteria(input_string):
157
  # Match both "Name: value [min-max]" and "Name [min-max]" formats
158
- match = re.match(r'(.+?)\s*:\s*([-+]?(?:\d*\.*\d+)(?:%)?)\s*\[([-+]?(?:\d*\.*\d+)(?:%)?)\s*-\s*([-+]?(?:\d*\.*\d+)(?:%)?)?\]', input_string)
159
  if match:
160
  name, value, min_val, max_val = match.groups()
161
  name = name.strip()
162
 
 
 
 
 
163
  # Handle percentage inputs
164
  is_percentage = '%' in value or '%' in min_val or '%' in max_val
165
  value = float(value.rstrip('%'))
@@ -167,7 +171,6 @@ def parse_quantitative_criteria(input_string):
167
  min_val = float(min_val.rstrip('%'))
168
  max_val = float(max_val.rstrip('%'))
169
 
170
-
171
  if is_percentage:
172
  value /= 100
173
  value = int(value)
 
155
 
156
  def parse_quantitative_criteria(input_string):
157
  # Match both "Name: value [min-max]" and "Name [min-max]" formats
158
+ match = re.match(r'(.+?)(?:\s*:\s*([-+]?(?:\d*\.*\d+)(?:%)?))?\s*\[([-+]?(?:\d*\.*\d+)(?:%)?)\s*-\s*([-+]?(?:\d*\.*\d+)(?:%)?)?\]', input_string)
159
  if match:
160
  name, value, min_val, max_val = match.groups()
161
  name = name.strip()
162
 
163
+ # Handle the case where value is None
164
+ if value is None:
165
+ return None # or you can raise an error, depending on your requirements
166
+
167
  # Handle percentage inputs
168
  is_percentage = '%' in value or '%' in min_val or '%' in max_val
169
  value = float(value.rstrip('%'))
 
171
  min_val = float(min_val.rstrip('%'))
172
  max_val = float(max_val.rstrip('%'))
173
 
 
174
  if is_percentage:
175
  value /= 100
176
  value = int(value)