From 5cb567bcf1baa90a227495ecb5b982fafcc4fcd9 Mon Sep 17 00:00:00 2001 From: Syed Mohammed Hubab Date: Tue, 30 Mar 2021 11:54:23 +0500 Subject: [PATCH] Updating isinstance() function in class _stem for compatibility with Python 3 The method _stem takes a word and checks if the encoding is in unicode. This was the syntax in older python versions. As I tried running this on my Python 3 project, it showed ''''NameError: name 'unicode' is not defined''' because unicode is deprecated. - In Python 2, str contains sequences of 8-bit values, unicode contains sequences of Unicode characters. - In Python 3, bytes contains sequences of 8-bit values, str contains sequences of Unicode characters. NOTE: This will work perfectly for Python 3. --- Stemmer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Stemmer.py b/Stemmer.py index 5094bd4..eb7dd2e 100644 --- a/Stemmer.py +++ b/Stemmer.py @@ -335,7 +335,7 @@ def stemWords(self, words): def _stem(cls, word): was_unicode = False - if isinstance(word, unicode): + if isinstance(word, bytes): was_unicode = True try: word = word.encode('ascii')