Bayan AI commited on
Commit
8fcecea
·
1 Parent(s): 72df81e

Fix: Strip trailing punctuation in grammar bypass rule to handle words at the end of sentences

Browse files
Files changed (1) hide show
  1. src/app.py +5 -3
src/app.py CHANGED
@@ -2102,9 +2102,11 @@ def analyze_text():
2102
  and len(orig_text) >= 3):
2103
  _is_grammar_pattern = True
2104
  # Present tense fem plural: ون → ن (يلعبون → يلعبن or يلعبون → تلعبن)
2105
- elif (orig_text.endswith('ون') and corr_text.endswith('ن') and len(orig_text) >= 3):
2106
- _o_stem = orig_text[:-2]
2107
- _c_stem = corr_text[:-1]
 
 
2108
  if _o_stem == _c_stem or (len(_o_stem) > 1 and _o_stem[1:] == _c_stem[1:] and _o_stem[0] in 'يت' and _c_stem[0] in 'يت'):
2109
  _is_grammar_pattern = True
2110
  # Present tense masc plural: يفعل→يفعلون (adding ون)
 
2102
  and len(orig_text) >= 3):
2103
  _is_grammar_pattern = True
2104
  # Present tense fem plural: ون → ن (يلعبون → يلعبن or يلعبون → تلعبن)
2105
+ elif (orig_text.rstrip('.,،؛;:!؟?()[]{}«»"\'…').endswith('ون') and corr_text.rstrip('.,،؛;:!؟?()[]{}«»"\'…').endswith('ن') and len(orig_text.rstrip('.,،؛;:!؟?()[]{}«»"\'…')) >= 3):
2106
+ _o_cl = orig_text.rstrip('.,،؛;:!؟?()[]{}«»"\'…')
2107
+ _c_cl = corr_text.rstrip('.,،؛;:!؟?()[]{}«»"\'…')
2108
+ _o_stem = _o_cl[:-2]
2109
+ _c_stem = _c_cl[:-1]
2110
  if _o_stem == _c_stem or (len(_o_stem) > 1 and _o_stem[1:] == _c_stem[1:] and _o_stem[0] in 'يت' and _c_stem[0] in 'يت'):
2111
  _is_grammar_pattern = True
2112
  # Present tense masc plural: يفعل→يفعلون (adding ون)