Well, you have declared and defined the load_classifier()
method but never called it and assigned a variable using it. That means, by the time, the execution reaches the print '\nSentiment is... '
line, there is no variable names classifier
. Naturally, the execution throws an exception.
Add the line classifier = load_classifier()
just before while loop. (without any indentation)