Skip to content

Commit 5a8fe71

Browse files
committed
Added fallback to False for characters that transliterate to the empty string in character classification utils functions
1 parent 4540176 commit 5a8fe71

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/error_align/utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ def is_vowel(c: str) -> bool:
9797
9898
"""
9999
assert len(c) == 1, "Input must be a single character."
100-
return unidecode(c)[0] in "aeiouy"
100+
decode_char = unidecode(c)
101+
if len(decode_char) == 0:
102+
return False
103+
return decode_char[0] in "aeiouy"
101104

102105

103106
def is_consonant(c: str) -> bool:
@@ -111,7 +114,10 @@ def is_consonant(c: str) -> bool:
111114
112115
"""
113116
assert len(c) == 1, "Input must be a single character."
114-
return unidecode(c)[0] in "bcdfghjklmnpqrstvwxyz"
117+
decode_char = unidecode(c)
118+
if len(decode_char) == 0:
119+
return False
120+
return decode_char[0] in "bcdfghjklmnpqrstvwxyz"
115121

116122

117123
def categorize_char(c: str) -> int:

0 commit comments

Comments
 (0)