Commit ·
9aa2ce8
1
Parent(s): 97062ad
fix(punctuation): allow pure punctuation changes through stage lock
Browse filesBEFORE: Spelling locks 'بشدة' → punctuation can't add period after it
AFTER: If diff only adds/moves punctuation marks (Arabic text unchanged),
allow it through the lock even on locked ranges
Lock still blocks any diff that changes actual Arabic words.
- src/app.py +14 -3
src/app.py
CHANGED
|
@@ -1155,12 +1155,23 @@ def analyze_text():
|
|
| 1155 |
diffs = get_word_diffs(ctx.current_text, corrected_punc)
|
| 1156 |
for d in diffs:
|
| 1157 |
# StageLocker: skip diffs that overlap with locked ranges
|
|
|
|
| 1158 |
if ctx.stage_locker.is_locked(d['start'], d['end']):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1159 |
logger.info(
|
| 1160 |
-
f"[LOCK] Punctuation
|
| 1161 |
-
f"'{d.get('original','')}'
|
| 1162 |
)
|
| 1163 |
-
continue
|
| 1164 |
# Punctuation safety layer: reject non-punctuation changes
|
| 1165 |
if not validate_punctuation_diff(d):
|
| 1166 |
logger.info(
|
|
|
|
| 1155 |
diffs = get_word_diffs(ctx.current_text, corrected_punc)
|
| 1156 |
for d in diffs:
|
| 1157 |
# StageLocker: skip diffs that overlap with locked ranges
|
| 1158 |
+
# BUT allow pure punctuation insertions near locked words
|
| 1159 |
if ctx.stage_locker.is_locked(d['start'], d['end']):
|
| 1160 |
+
import re as _re
|
| 1161 |
+
orig_alpha = _re.sub(r'[^\u0600-\u06FFa-zA-Z]', '', d.get('original', ''))
|
| 1162 |
+
corr_alpha = _re.sub(r'[^\u0600-\u06FFa-zA-Z]', '', d.get('correction', ''))
|
| 1163 |
+
if orig_alpha != corr_alpha:
|
| 1164 |
+
# Diff changes actual words — block it
|
| 1165 |
+
logger.info(
|
| 1166 |
+
f"[LOCK] Punctuation blocked on [{d['start']}:{d['end']}] "
|
| 1167 |
+
f"'{d.get('original','')}' \u2014 locked by previous stage"
|
| 1168 |
+
)
|
| 1169 |
+
continue
|
| 1170 |
+
# Arabic text unchanged \u2014 only punctuation added/moved. Allow through.
|
| 1171 |
logger.info(
|
| 1172 |
+
f"[LOCK] Punctuation ALLOWED through lock [{d['start']}:{d['end']}] "
|
| 1173 |
+
f"'{d.get('original','')}' \u2192 '{d.get('correction','')}' \u2014 pure punctuation"
|
| 1174 |
)
|
|
|
|
| 1175 |
# Punctuation safety layer: reject non-punctuation changes
|
| 1176 |
if not validate_punctuation_diff(d):
|
| 1177 |
logger.info(
|