youssefreda9 commited on
Commit
8374b8c
·
1 Parent(s): b85e858

Fix SC013 structured data punctuation guard

Browse files
Files changed (1) hide show
  1. src/app.py +8 -1
src/app.py CHANGED
@@ -2670,7 +2670,14 @@ def analyze_text():
2670
  # FIX-52: Universal Structured Data protection for punctuation
2671
  import re as _re_struct_univ
2672
  _p_orig = d.get('original', '')
2673
- if _p_orig and (any(c.isdigit() for c in _p_orig) or _re_struct_univ.search(r'[a-zA-Z]|\{|\[|<|#|@|://', _p_orig)):
 
 
 
 
 
 
 
2674
  logger.info(
2675
  f"[PUNC-SAFETY] Blocked structured data punct diff: "
2676
  f"'{_p_orig}' → '{d.get('correction','')}'"
 
2670
  # FIX-52: Universal Structured Data protection for punctuation
2671
  import re as _re_struct_univ
2672
  _p_orig = d.get('original', '')
2673
+ _p_end_idx = d.get('end', 0)
2674
+ _p_next_text = ctx.current_text[_p_end_idx:].lstrip()
2675
+ _p_next_word = _p_next_text.split()[0] if _p_next_text else ''
2676
+
2677
+ _is_orig_struct = _p_orig and (any(c.isdigit() for c in _p_orig) or _re_struct_univ.search(r'[a-zA-Z]|\{|\[|<|#|@|://', _p_orig))
2678
+ _is_next_struct = _p_next_word and (any(c.isdigit() for c in _p_next_word) or _re_struct_univ.search(r'[a-zA-Z]|\{|\[|<|#|@|://', _p_next_word))
2679
+
2680
+ if _is_orig_struct or _is_next_struct:
2681
  logger.info(
2682
  f"[PUNC-SAFETY] Blocked structured data punct diff: "
2683
  f"'{_p_orig}' → '{d.get('correction','')}'"