Code Monkey home page Code Monkey logo

twitter_polarization's Introduction

twitter_polarization

This project performs topic and sentiment analysis on an arabic & english datasets from the hashtags #JerusalemEmbassy and #القدس_عاصمة_فلسطين_الابدية and then creates graphml files that visualize the dataset and political sides it contains. The following steps are a walk-through for the mentioned process.

English dataset

This dataset is divided into 3 phases:

  1. Phase 1: Dec 6 2017 to Jan 20 2018.
  2. Phase 2: Jan 21 2018 to May 09 2018.
  3. Phase 3: May 10 2018 to May 24 2018.

The English dataset can be found in dataset/phase1 , dataset/phase2 and dataset/phase3. Each phase contains 3 csv files: 1 for replies, and 1 for the tweets that are replied to, and a third for non-reply tweets. The following is the sequence to follow for recreating the project for the English dataset:

  1. topicSentimentEnglish.py creates an LDA model and assigns each tweet a topic and adds a sentiment column. The resulting dataframes can be found in the folder topic_sentiment_pickles .
  2. topic_sentiment_dfs.ipynb is a notebook that separates all tweets that belong to the same topic with the same sentiment in a dataframe (e.g: the dataframe neg3_phase1 contains all the tweets from topic 3 with a negative sentiment in phase 1). The resulting dataframes can be found in the folder topic_sentiment_dfs.
  3. wordCloudGeneratorEnglish.py contains the code to generate wordclouds from the dataframes in topic_sentiment_dfs folder. The resulting wordclouds can be found in the folder wordclouds
  4. Creating the graph files: to create the graphs for each phase the following files should be run in the order specified below (Note that phaseX means phase1 or phase2 or phase3):
    1. phaseX_repliedto_graph.py

    2. phaseX_replies_graph.py

    3. phaseX_tweets_graph.py

    4. phaseX_full_graph_POL.py (This groups nodes according to political pole)

      OR

    5. phaseX_full_graph_TS.py (This groups nodes according to topic + sentiment)

The resulting graph files can be found in full_graphs_POL and full_graphs_TS folders depending on the selected step v

  1. To label boundary nodes and edges and get the boundary score, the following files should be run in the order specified below:

    1. phaseX_labeling_boundary_nodes.py
    2. phaseX_labeling_boundary_edges.py
    3. phaseX_boundary_score_calculation.py

    The resulting files can be found in boundary_labeled_graphs

Arabic dataset

This dataset covers tweets from the phase defined above as phase 3. The Arabic dataset can be found in dataset/arabic The following is the sequence to follow for recreating the project for the Arabic dataset:

  1. arabic_topic_extraction.ipynb performs manual topic mapping through looking for keywords in tweets. The resulting grouping can be found in arabic_topic_dfs folder
  2. Creating the graph files: to create the graphs for the Arabic dataset the following files should be run in the order specified below
    1. arabic_repliedto_graph.py
    2. arabic_replies_graph.py
    3. arabic_tweets_graph.py
    4. arabic_full_graph.py

The resulting graphs can be found in the full_graph_arabic folder

  1. To label boundary nodes and edges and get the boundary score, the following files should be run in the order specified below:

    1. arabic_labeling_boundary_nodes.py
    2. arabic_labeling_boundary_edges.py
    3. arabic_boundary_score_calculation.py

    The resulting files can be found in boundary_labeled_graphs

twitter_polarization's People

Contributors

yasmeenhany avatar

Watchers

James Cloos avatar

Forkers

bobycv06fpm

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.