Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np;
- import matplotlib.pyplot as plot
- lexiconSentiment = np.genfromtxt("list_of_lexicon_value.csv", delimiter = ',', dtype = [('f0', 'S24'), ('f1', '<f8')])
- userInput = input("Enter the file-name: ")
- textFileIntoArray = np.genfromtxt(userInput, delimiter = ' ', dtype = 'str')
- booleanValues = np.in1d(lexiconSentiment['f0'], textFileIntoArray)
- listOfSentimentNumberValue = []
- the size of booleanValue
- for x in range(0,booleanValues.size):
- if booleanValues[x]:
- listOfSentimentNumberValue.append(lexiconSentiment['f1'][x])
- print lexiconSentiment['f0'][x]
- xLabelDescription = ["Negative", "Weakly Negative", "Neutral", "Weakly Positive", "Positive"]
- plot.xlabel("Sentiment"); plot.ylabel("Percent of Words")
- 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)
- label_pos = [-0.75,-0.25,0.25,0.75,1.25]
- plot.xticks(label_pos, xLabelDescription)
Add Comment
Please, Sign In to add comment