Skip to content

Commit

Permalink
Remove isascii compat for <=3.7
Browse files Browse the repository at this point in the history
3.7 is EOL so support will be removed in the next version.
  • Loading branch information
polm committed Oct 11, 2023
1 parent 3e3c996 commit e403fe1
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions cutlet/cutlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,6 @@
'nihon': NIHONSHIKI,
}

if sys.version_info >= (3, 7):
def is_ascii(s):
"""Check if a given string is ASCII."""
return s.isascii()
else:
def is_ascii(s):
"""Check if a given string is ASCII."""
# this version is for old Pythons
for c in s:
if c > '\x7f':
return False
return True

def has_foreign_lemma(word):
"""Check if a word (node) has a foreign lemma.
Expand All @@ -62,7 +49,7 @@ def has_foreign_lemma(word):
# NOTE: some words have 外国 instead of a foreign spelling. ジル
# (Jill?) is an example. Unclear why this is the case.
# There are other hyphenated lemmas, like 私-代名詞.
if is_ascii(cand):
if cand.isascii():
return True

def normalize_text(text):
Expand Down Expand Up @@ -322,7 +309,7 @@ def romaji_word(self, word):
if word.surface.isdigit():
return word.surface

if is_ascii(word.surface):
if word.surface.isascii():
return word.surface

# deal with unks first
Expand Down

0 comments on commit e403fe1

Please sign in to comment.