Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deepmoji/filter_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def shorten_word(word):

# only shorten ASCII words
try:
word.decode('ascii')
word.encode().decode('ascii')
except (UnicodeDecodeError, UnicodeEncodeError) as e:
return word

Expand Down
4 changes: 2 additions & 2 deletions deepmoji/word_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_words(self, sentence):
that is not allowed.
"""

if not isinstance(sentence, unicode):
if not isinstance(sentence, str):
raise ValueError("All sentences should be Unicode-encoded!")
sentence = sentence.strip().lower()

Expand Down Expand Up @@ -96,7 +96,7 @@ def check_ascii(self, word):
""" Returns whether a word is ASCII """

try:
word.decode('ascii')
word.encode().decode('ascii')
return True
except (UnicodeDecodeError, UnicodeEncodeError):
return False
Expand Down