Spaces:
Sleeping
Sleeping
Update contractapp_forapi.py
Browse files- contractapp_forapi.py +4 -1
contractapp_forapi.py
CHANGED
@@ -48,15 +48,18 @@ 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 |
lines = text.splitlines()
|
52 |
for i, line in enumerate(lines):
|
53 |
if "Dátum" in line:
|
54 |
-
|
55 |
context_lines = lines[i-1:i+1] if i > 0 else [line]
|
56 |
for ctx in reversed(context_lines):
|
57 |
match = re.search(r'\d{4}-\d{2}-\d{2}', ctx)
|
58 |
if match:
|
|
|
59 |
return match.group()
|
|
|
60 |
return None
|
61 |
pattern = re.escape(label) + r'[:\s]*([^\n]+)'
|
62 |
match = re.search(pattern, text)
|
|
|
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 |
context_lines = lines[i-1:i+1] if i > 0 else [line]
|
57 |
for ctx in reversed(context_lines):
|
58 |
match = re.search(r'\d{4}-\d{2}-\d{2}', ctx)
|
59 |
if match:
|
60 |
+
print(f"✅ Extracted date from context: {match.group()}")
|
61 |
return match.group()
|
62 |
+
print("❌ No date found near 'Dátum'")
|
63 |
return None
|
64 |
pattern = re.escape(label) + r'[:\s]*([^\n]+)'
|
65 |
match = re.search(pattern, text)
|