Guest User

Untitled

a guest
Oct 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import numpy as np;
  2. import matplotlib.pyplot as plot
  3.  
  4. lexiconSentiment = np.genfromtxt("list_of_lexicon_value.csv", delimiter = ',', dtype = [('f0', 'S24'), ('f1', '<f8')])
  5.  
  6. userInput = input("Enter the file-name: ")
  7.  
  8. textFileIntoArray = np.genfromtxt(userInput, delimiter = ' ', dtype = 'str')
  9.  
  10. booleanValues = np.in1d(lexiconSentiment['f0'], textFileIntoArray)
  11.  
  12. listOfSentimentNumberValue = []
  13.  
  14. the size of booleanValue
  15. for x in range(0,booleanValues.size):
  16. if booleanValues[x]:
  17. listOfSentimentNumberValue.append(lexiconSentiment['f1'][x])
  18. print lexiconSentiment['f0'][x]
  19.  
  20. xLabelDescription = ["Negative", "Weakly Negative", "Neutral", "Weakly Positive", "Positive"]
  21.  
  22. plot.xlabel("Sentiment"); plot.ylabel("Percent of Words")
  23.  
  24. plot.hist(listOfSentimentNumberValue, bins = (-1.0,-0.5,0.0,0.5,1.0,1.5), color = 'blue', range = (0.0, 0.0), normed = True)
  25.  
  26. label_pos = [-0.75,-0.25,0.25,0.75,1.25]
  27.  
  28. plot.xticks(label_pos, xLabelDescription)
Add Comment
Please, Sign In to add comment