gaurv007 commited on
Commit
3116f23
·
verified ·
1 Parent(s): 584624e

v3.1: Fix 7-8 — party attribution scoped to sentence, reject >40 char strings

Browse files
Files changed (1) hide show
  1. obligations.py +12 -8
obligations.py CHANGED
@@ -120,18 +120,22 @@ def extract_obligations(text):
120
  if not found_types:
121
  continue
122
 
123
- # Extract party
124
  party = "Unknown"
125
- for pp in PARTY_PATTERNS:
126
- m = re.search(pp, sentence)
127
- if m:
128
- party = m.group(0).strip()
129
- break
130
-
131
- # Try to determine which party has the obligation based on sentence structure
132
  obligation_direction = _detect_obligation_direction(sentence)
133
  if obligation_direction:
134
  party = obligation_direction
 
 
 
 
 
 
 
 
 
 
135
 
136
  # Extract timeframe
137
  deadline = "Not specified"
 
120
  if not found_types:
121
  continue
122
 
123
+ # Extract party (Fix 8: scope to sentence only, reject >40 char strings)
124
  party = "Unknown"
125
+ # First try structured direction detection
 
 
 
 
 
 
126
  obligation_direction = _detect_obligation_direction(sentence)
127
  if obligation_direction:
128
  party = obligation_direction
129
+ else:
130
+ # Fallback to pattern matching within the sentence
131
+ for pp in PARTY_PATTERNS:
132
+ m = re.search(pp, sentence)
133
+ if m:
134
+ candidate = m.group(0).strip()
135
+ # Fix 8: Reject party strings >40 chars (header bleed-through)
136
+ if len(candidate) <= 40:
137
+ party = candidate
138
+ break
139
 
140
  # Extract timeframe
141
  deadline = "Not specified"