Coder Social home page Coder Social logo

sentimentsanalysis's Introduction

Sentiments Analysis using Python

Sources

After reading an interesting tutorial on Kaggle about Sentiments Analysis applied to American Political Speeches, I decided to create my own version.

Instead of using R, I used Python and I applied my model to French Political Speeches.

I used the lexicons available here, which are from the following paper : Chen, Y., & Skiena, S. (2014). Building Sentiment Lexicons for All Major Languages. In ACL (2) (pp. 383-389).

I used the speeches available on this page.

Code

I used a Class Speech which contains the following:

  • name of the speaker (Here, the name of the President)
  • year of the speech
  • number of positive words in the speech
  • number of negative words in the speech
  • number of words in the speech
  • a ratio, (number of positive words - number of negative words)/(number of words).

I created a function getLexicons(positiveList, negativeList) which put all the positive words from the positive lexicon into a list, and put all the negative words from the negative lexicon into another list.

I then created another function getSpeechAnalysis(speechName, name, year, positiveList, negativeList) which return a speech class with all the information we need (number of words, number of positive/negative words...).

Then, after initializing the environment with the first function, I applied this last function to a list of speeches (the end-of-the-year speech given by the Frencg President).

Results

I obtained the following results:

  • On this graphe, we can see the positivness ratio evolving among time. We can see where the different Presidents position themselves compared to the moving average. Alt text

  • On this graphe, I draw a boxplot for every President. Thus, we can see the median, the first and third quartile, the maximum and the minimum for every President. Alt text

sentimentsanalysis's People

Contributors

cga83 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.