Spaces:
Build error
Build error
Update esg_metrics.py
Browse files- esg_metrics.py +5 -12
esg_metrics.py
CHANGED
|
@@ -1,24 +1,17 @@
|
|
| 1 |
import re
|
| 2 |
|
| 3 |
-
def extract_scope(text,
|
| 4 |
-
pattern = rf"Scope\s*{scope}[^0-9]*(\d+\.?\d*)"
|
| 5 |
-
m = re.search(pattern, text, re.IGNORECASE)
|
| 6 |
-
if m:
|
| 7 |
|
| 8 |
-
|
| 9 |
|
| 10 |
-
return None
|
| 11 |
|
| 12 |
|
| 13 |
def extract_revenue(text):
|
| 14 |
|
| 15 |
-
m = re.search(r"Revenue[^0-9]*(\d+\.?\d*)", text, re.
|
| 16 |
|
| 17 |
-
if m
|
| 18 |
-
|
| 19 |
-
return float(m.group(1))
|
| 20 |
-
|
| 21 |
-
return None
|
| 22 |
|
| 23 |
|
| 24 |
def carbon_intensity(scope1, revenue):
|
|
|
|
| 1 |
import re
|
| 2 |
|
| 3 |
+
def extract_scope(text, n):
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
m = re.search(rf"Scope\s*{n}[^0-9]*(\d+\.?\d*)", text, re.I)
|
| 6 |
|
| 7 |
+
return float(m.group(1)) if m else None
|
| 8 |
|
| 9 |
|
| 10 |
def extract_revenue(text):
|
| 11 |
|
| 12 |
+
m = re.search(r"Revenue[^0-9]*(\d+\.?\d*)", text, re.I)
|
| 13 |
|
| 14 |
+
return float(m.group(1)) if m else None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
def carbon_intensity(scope1, revenue):
|