I try to use nltk to do some words processing, but there is a warning. I find out the if there is the word like “Nations�“, the program would throw a warning. I wonder if there is any way to stop the program after the warning caused. Thank you
*UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal if word.lower() not in stopwords.words():*
A warning is a non-fatal error. Something is wrong, but the program can continue.
They can be handled with the standard library module
warnings or through the command line, passing the flag
import warnings with warnings.catch_warnings(): warnings.simplefilter('error') function_raising_warning()