Spaces:
Sleeping
Sleeping
Update contractapp_forapi.py
Browse files- contractapp_forapi.py +8 -7
contractapp_forapi.py
CHANGED
@@ -48,19 +48,20 @@ def set_nested(data, key_path, value):
|
|
48 |
# Helper: extract value using regex
|
49 |
def extract_value(label, text, label_list):
|
50 |
if label == "Dátum":
|
51 |
-
print("⚠️ Handling 'Dátum' label...")
|
52 |
lines = text.splitlines()
|
53 |
for i, line in enumerate(lines):
|
54 |
if "Dátum" in line:
|
55 |
print(f"✅ Found line with 'Dátum': {line}")
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
59 |
if match:
|
60 |
-
print(f"✅ Extracted date
|
61 |
return match.group()
|
62 |
-
|
63 |
-
|
|
|
64 |
pattern = re.escape(label) + r'[:\s]*([^\n]+)'
|
65 |
match = re.search(pattern, text)
|
66 |
if match:
|
|
|
48 |
# Helper: extract value using regex
|
49 |
def extract_value(label, text, label_list):
|
50 |
if label == "Dátum":
|
|
|
51 |
lines = text.splitlines()
|
52 |
for i, line in enumerate(lines):
|
53 |
if "Dátum" in line:
|
54 |
print(f"✅ Found line with 'Dátum': {line}")
|
55 |
+
if i > 0:
|
56 |
+
previous_line = lines[i - 1]
|
57 |
+
print(f"🔍 Checking previous line: {previous_line}")
|
58 |
+
match = re.search(r'\d{4}-\d{2}-\d{2}', previous_line)
|
59 |
if match:
|
60 |
+
print(f"✅ Extracted date: {match.group()}")
|
61 |
return match.group()
|
62 |
+
print("❌ No date found in previous line")
|
63 |
+
return None
|
64 |
+
|
65 |
pattern = re.escape(label) + r'[:\s]*([^\n]+)'
|
66 |
match = re.search(pattern, text)
|
67 |
if match:
|