Commit
·
f8700a5
1
Parent(s):
34addbf
Should now correctly extract and sum up total processing time
Browse files- tools/file_redaction.py +6 -6
tools/file_redaction.py
CHANGED
@@ -47,20 +47,20 @@ def choose_and_run_redactor(file_paths:List[str], image_paths:List[str], languag
|
|
47 |
#final_out_message = final_out_message + "\n\nGo to to the Redaction settings tab to see redaction logs. Please give feedback on the results below to help improve this app."
|
48 |
|
49 |
def sum_numbers_from_string(string):
|
50 |
-
"""Extracts all numbers from a string and adds them up.
|
51 |
|
52 |
Args:
|
53 |
string: The input string.
|
54 |
|
55 |
-
Returns:
|
56 |
The sum of all numbers extracted from the string.
|
57 |
"""
|
58 |
|
59 |
-
# Extract all numbers using regular expression
|
60 |
-
numbers = re.findall(r'\d+', string)
|
61 |
|
62 |
-
# Convert the numbers to
|
63 |
-
sum_of_numbers = sum(
|
64 |
|
65 |
return sum_of_numbers
|
66 |
|
|
|
47 |
#final_out_message = final_out_message + "\n\nGo to to the Redaction settings tab to see redaction logs. Please give feedback on the results below to help improve this app."
|
48 |
|
49 |
def sum_numbers_from_string(string):
|
50 |
+
"""Extracts all numbers from a string and adds them up, including numbers with decimals.
|
51 |
|
52 |
Args:
|
53 |
string: The input string.
|
54 |
|
55 |
+
Returns:s
|
56 |
The sum of all numbers extracted from the string.
|
57 |
"""
|
58 |
|
59 |
+
# Extract all numbers using regular expression, allowing for decimals
|
60 |
+
numbers = re.findall(r'\d+(\.\d+)?', string)
|
61 |
|
62 |
+
# Convert the numbers to floats and sum them up
|
63 |
+
sum_of_numbers = sum(float(num) for num in numbers)
|
64 |
|
65 |
return sum_of_numbers
|
66 |
|