Skip to content

Instantly share code, notes, and snippets.

@vaibhavgehani
Created July 26, 2020 17:24
Show Gist options
  • Select an option

  • Save vaibhavgehani/e174897a80595d8087fff4bd93ebb60b to your computer and use it in GitHub Desktop.

Select an option

Save vaibhavgehani/e174897a80595d8087fff4bd93ebb60b to your computer and use it in GitHub Desktop.
classifier=pickle.load(open('classifier.pkl','rb'))
def extract_features(word_list):
return dict([(word, True) for word in word_list])
def predictSentiment(text):
print('predict Sentiement',text)
probdist = classifier.prob_classify(extract_features(text.split()))
pred_sentiment = probdist.max()
print("Predicted sentiment: ", pred_sentiment)
return pred_sentiment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment