Use Twitter Messages to analyze people’s emotions
Introduction and my thoughts
Automatic analysis of the emotions people express in their blogs seems to be a distant topic, which involves not only programming to control machines and language recognition, but also how to combine the two. And when the topic came up with Python, it became easier. The method we use is to look for emotive keywords in a blog and assign a score to them, then calculate the score to determine the mood of the blogger. Although it is the simplest model, it is a useful method; And, at the same time, it’s a great way to familiarize myself with Python – something I can only master with practice. When I pressed the “run” button, thousands of scores appeared in front of my eyes, and all the emotional or humorous or excited words were digitized and turned into scores.
If you think about it, what’s the use of analyzing your mood? It has many USES, such as analyzing the comments on an article, whether they are positive or negative, so that we can quickly figure out how well the article is doing, and then we can easily improve it. The same is true for a commodity, and so on and so forth. But it also begs the question: Can machines really analyze people?It’s just that these simple words don’t even make it clear whether the word describes them or something else.
More deeply, even though the same words may have different meanings, like irony, the model is indistinguishable. So if you want to refine this function, you have to have other discriminative conditions, not just simple words. Not only is there a long way to go, but the only way to enhance its function is to accumulate experience, and participating in such activities is a good way.
steps
1 | jing=[] |
1 | #read in the keywords with the value they have to make a dictionary |
{‘alone’: 1, ‘amazed’: 10, ‘amazing’: 10, ‘bad’: 1, ‘best’: 10, ‘better’: 10, ‘excellent’: 10, ‘excited’: 10, ‘excite’: 10, ‘excites’: 10, ‘exciting’: 10, ‘glad’: 10, ‘god’: 5, ‘good’: 7, ‘great’: 7, ‘greatest’: 10, ‘haha’: 5, ‘hahaha’: 5, ‘happy’: 10, ‘hate’: 1, ‘hurt’: 1, ‘hurts’: 1, ‘hurting’: 1, ‘like’: 7, ‘likes’: 7, ‘liked’: 7, ‘lol’: 5, ‘lonely’: 1, ‘love’: 10, ‘loves’: 10, ‘loved’: 10, ‘loving’: 10, ‘lovin’: 10, ‘need’: 1, ‘needs’: 1, ‘negative’: 1, ‘please’: 5, ‘positive’: 7, ‘pretty’: 10, ‘prettiest’: 10, ‘regret’: 1, ‘regrets’: 1, ‘ruin’: 1, ‘ruins’: 1, ‘ruined’: 1, ‘sad’: 1, ‘save’: 5, ‘saves’: 5, ‘saved’: 5, ‘sorry’: 1, ‘thank’: 5, ‘thanks’: 5, ‘tired’: 1, ‘worst’: 1}
1 | #compare each words with keywords and calculate the score each message gets |
1 | #get their longitude and latitude in one list |
finally we can calculate the average score in different areas:
1 | s1=0 |
6920 2970 653 1767 501