Spaces:
Sleeping
Sleeping
class ParameterExtractor: | |
def __init__(self, query): | |
self.query = query.lower() | |
def extract_integers(self): | |
extracted_integers = [] | |
current_number = "" | |
for char in self.query: | |
if char.isdigit(): | |
# Append digits to the current number | |
current_number += char | |
elif current_number: | |
# If a number is complete, convert and append it | |
extracted_integers.append(int(current_number)) | |
current_number = "" # Reset current_number | |
# Check for any remaining numbers after the loop | |
if current_number: | |
extracted_integers.append(int(current_number)) | |
sorted_integers = sorted(extracted_integers) | |
return sorted_integers | |