youssefreda9 Claude Opus 4.6 commited on
Commit
3ab74e1
·
1 Parent(s): df5e501

fix(punctuation): extend colon guard to preposition+definite-article prefixes

Browse files

The colon guard only stripped colons from ال-prefixed words, missing
preposition+definite combos like لل (للطالبة:). This fixes PC037 where
a hallucinated colon after a speech verb's indirect object survived
postprocessing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

src/nlp/punctuation/punctuation_rules.py CHANGED
@@ -66,9 +66,9 @@ def arabic_postprocessing(text: str) -> str:
66
  prev_word = match.group(1)
67
  if re.fullmatch(_ALLOWED_COLON_CUES, prev_word):
68
  return match.group(0)
69
- # If it's a definite noun (starts with ال) and not in allowed list, it's hallucinated.
70
- # Remove the colon entirely — replacing with comma is also wrong (e.g. الشمس، مشرقة)
71
- if prev_word.startswith('ال'):
72
  return f'{prev_word}'
73
  return match.group(0)
74
 
 
66
  prev_word = match.group(1)
67
  if re.fullmatch(_ALLOWED_COLON_CUES, prev_word):
68
  return match.group(0)
69
+ # Strip colons from definite nouns (ال-prefix) and preposition+definite combos
70
+ # (لل, بال, فال, وال, كال). These are never valid colon targets.
71
+ if prev_word.startswith(('ال', 'لل', 'بال', 'فال', 'وال', 'كال')):
72
  return f'{prev_word}'
73
  return match.group(0)
74