Spaces:
Running
Running
v4.2: Update compliance.py
Browse files- compliance.py +7 -4
compliance.py
CHANGED
|
@@ -23,6 +23,9 @@ _NEGATION_PATTERNS = [
|
|
| 23 |
r"notwithstanding.*(?:shall\s+not|does\s+not|is\s+not)",
|
| 24 |
]
|
| 25 |
|
|
|
|
|
|
|
|
|
|
| 26 |
# Regulatory requirement definitions
|
| 27 |
REGULATIONS = {
|
| 28 |
"GDPR": {
|
|
@@ -214,13 +217,13 @@ def _check_negation(text_lower, keyword, window=200):
|
|
| 214 |
wider_context = text_lower[start:end]
|
| 215 |
|
| 216 |
# Check sentence first (higher confidence)
|
| 217 |
-
for neg_pat in
|
| 218 |
-
if
|
| 219 |
return True
|
| 220 |
|
| 221 |
# Then check wider window (lower confidence, still relevant)
|
| 222 |
-
for neg_pat in
|
| 223 |
-
if
|
| 224 |
return True
|
| 225 |
|
| 226 |
return False
|
|
|
|
| 23 |
r"notwithstanding.*(?:shall\s+not|does\s+not|is\s+not)",
|
| 24 |
]
|
| 25 |
|
| 26 |
+
# FIX v4.2: Pre-compile negation patterns at module level
|
| 27 |
+
_NEGATION_PATTERNS_COMPILED = [re.compile(p, re.IGNORECASE) for p in _NEGATION_PATTERNS]
|
| 28 |
+
|
| 29 |
# Regulatory requirement definitions
|
| 30 |
REGULATIONS = {
|
| 31 |
"GDPR": {
|
|
|
|
| 217 |
wider_context = text_lower[start:end]
|
| 218 |
|
| 219 |
# Check sentence first (higher confidence)
|
| 220 |
+
for neg_pat in _NEGATION_PATTERNS_COMPILED:
|
| 221 |
+
if neg_pat.search(sentence):
|
| 222 |
return True
|
| 223 |
|
| 224 |
# Then check wider window (lower confidence, still relevant)
|
| 225 |
+
for neg_pat in _NEGATION_PATTERNS_COMPILED[:4]: # Only strong negation patterns for wider window
|
| 226 |
+
if neg_pat.search(wider_context):
|
| 227 |
return True
|
| 228 |
|
| 229 |
return False
|