MilanM commited on
Commit
3bdea97
·
verified ·
1 Parent(s): 49417eb

Update pdf_generator.py

Browse files
Files changed (1) hide show
  1. pdf_generator.py +9 -10
pdf_generator.py CHANGED
@@ -156,28 +156,27 @@ def process_quantitative_criteria(answer, styles):
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 '') or '%' in min_val or '%' in max_val
165
-
166
- # Convert to float, handling None values
167
  min_val = float(min_val.rstrip('%'))
168
  max_val = float(max_val.rstrip('%'))
169
- value = float(value.rstrip('%')) if value else (min_val + max_val) / 2 # Default to middle of range if no value given
170
 
171
  if is_percentage:
172
  value /= 100
173
- min_val /= 100
174
- max_val /= 100
175
-
176
- # Determine if the values should be integers or floats
177
- if value.is_integer() and min_val.is_integer() and max_val.is_integer():
178
  value = int(value)
179
  min_val = int(min_val)
180
  max_val = int(max_val)
 
 
 
 
181
 
182
  return name, value, min_val, max_val, is_percentage
183
  return None
 
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('%'))
166
+
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)
174
  min_val = int(min_val)
175
  max_val = int(max_val)
176
+ else:
177
+ value = float(value)
178
+ min_val = float(min_val)
179
+ max_val = float(max_val)
180
 
181
  return name, value, min_val, max_val, is_percentage
182
  return None