How to store and use data from a text file in python for sentiment-analysis?

Viewed 126

So I'm writing a sentimental analysis program where I would be summing up the emotions of a character in a text file based on the words used in the sentence. I would be using the data from NRC Emotion Intensity Lexicon text file which contains data under the heading of word, emotion, and emotion-intensity score as shown in a snippet of the file below:

adultery   anger 0
adultery   anticipation     0
adultery   disgust  1
adultery   fear  0
adultery   joy  0
adultery   negative   1
adultery   positive   0
adultery   sadness  1
adultery   surprise   0
adultery   trust 0
dislike anger 1
dislike anticipation    0
dislike disgust 1
dislike fear  0
dislike joy  0
dislike negative   1
dislike positive   0
dislike sadness 0
dislike surprise   0
dislike trust 0

So if I had a sentence like: "People dislike adultery", I would produce an emotion score for each of the emotions as:

anger = 1 ; anticipation = 0 ; disgust = 1; fear = 0; joy = 0 ; negative = 2 ; positive = 0 ; sadness = 1 ; surprise = 0 ; trust = 0.

Currently, I'm thinking of how to store the emotion data in my python program. It's around 400k worth of words. I was thinking that I could use a dictionary to store the words as key and emotion and emotion-intensity score in a list as values, but I'm not sure if that's a feasible way of going about it, as I would need to access all the emotion intensity together with the scores of the word. I'm open to suggestions and ideas as to how to process and store the data from the text file into my program.

0 Answers
Related