SoumyaJ commited on
Commit
9c55a16
·
verified ·
1 Parent(s): b33898f

Update contractapp_forapi.py

Browse files
Files changed (1) hide show
  1. contractapp_forapi.py +11 -0
contractapp_forapi.py CHANGED
@@ -47,6 +47,17 @@ def set_nested(data, key_path, value):
47
 
48
  # Helper: extract value using regex
49
  def extract_value(label, text, label_list):
 
 
 
 
 
 
 
 
 
 
 
50
  pattern = re.escape(label) + r'[:\s]*([^\n]+)'
51
  match = re.search(pattern, text)
52
  if match:
 
47
 
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
+ # Check previous lines (or same line) for a date
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)
63
  if match: