Spaces:
Sleeping
Sleeping
Update contractapp_forapi.py
Browse files- contractapp_forapi.py +12 -8
contractapp_forapi.py
CHANGED
@@ -52,16 +52,20 @@ def extract_value(label, text, label_list):
|
|
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
|
56 |
-
|
57 |
-
print(f"🔍 Checking
|
58 |
-
|
59 |
-
if
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
63 |
return None
|
64 |
|
|
|
65 |
pattern = re.escape(label) + r'[:\s]*([^\n]+)'
|
66 |
match = re.search(pattern, text)
|
67 |
if match:
|
|
|
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 + 1 < len(lines):
|
56 |
+
next_line = lines[i + 1]
|
57 |
+
print(f"🔍 Checking next line: {next_line}")
|
58 |
+
dates = re.findall(r'\d{4}-\d{2}-\d{2}', next_line)
|
59 |
+
if len(dates) >= 2:
|
60 |
+
combined = f"{dates[0]} - {dates[1]}"
|
61 |
+
print(f"✅ Combined dates: {combined}")
|
62 |
+
return combined
|
63 |
+
elif len(dates) == 1:
|
64 |
+
return dates[0] # fallback: only one date found
|
65 |
+
print("❌ No date found in next line")
|
66 |
return None
|
67 |
|
68 |
+
|
69 |
pattern = re.escape(label) + r'[:\s]*([^\n]+)'
|
70 |
match = re.search(pattern, text)
|
71 |
if match:
|