Krixter commited on
Commit
23dc6d1
·
verified ·
1 Parent(s): 917a94d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -43,9 +43,15 @@ def clean_outer(word: str) -> str:
43
  return word.strip(OUTER_PUNCT)
44
 
45
 
 
 
 
 
 
 
46
  def _segment_is_clean(segment: str) -> bool:
47
- """A hyphen-joined chunk is 'clean' if it's pure letters(+apostrophe)
48
- or pure digits or empty (e.g. '36', 'year', 'old' in 36-year-old)."""
49
  if segment == "":
50
  return True
51
  if segment.isdigit():
@@ -90,8 +96,9 @@ def is_mixup_word(word: str):
90
  return False, cleaned # legit hyphenated word -> skip
91
  return True, cleaned # a chunk is disguised -> flag
92
 
93
- # No hyphen: flag if letters are mixed with digits/specials anywhere
94
- has_other = any((not c.isalpha()) for c in cleaned)
 
95
  if has_other:
96
  return True, cleaned
97
 
 
43
  return word.strip(OUTER_PUNCT)
44
 
45
 
46
+ def _is_plain_ascii_alpha(c: str) -> bool:
47
+ """True only for plain a-z/A-Z letters (excludes accented letters
48
+ like é, ú, ñ, ü -- those are treated as 'suspicious' below)."""
49
+ return c.isalpha() and c.isascii()
50
+
51
+
52
  def _segment_is_clean(segment: str) -> bool:
53
+ """A hyphen-joined chunk is 'clean' if it's pure plain letters
54
+ (+apostrophe) or pure digits or empty (e.g. '36', 'year', 'old')."""
55
  if segment == "":
56
  return True
57
  if segment.isdigit():
 
96
  return False, cleaned # legit hyphenated word -> skip
97
  return True, cleaned # a chunk is disguised -> flag
98
 
99
+ # No hyphen: flag if plain letters are mixed with digits/symbols/
100
+ # accented look-alike letters (é, ú, ñ, ü...) anywhere in the word
101
+ has_other = any(not _is_plain_ascii_alpha(c) for c in cleaned)
102
  if has_other:
103
  return True, cleaned
104