yiyang-gt / social-attention

Code for the TACL paper "Overcoming Language Variation in Sentiment Analysis with Social Attention"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sentiment Analysis with Social Attention

Author: Yi Yang

Contact: yangyiycc@gmail.com

Basic description

This is the Python implementation of the social attention model for sentiment analysis, described in

Yi Yang and Jacob Eisenstein "Overcoming Language Variation in Sentiment Analysis with Social Attention", TACL 2017

[pdf], [BibTex]

Dependencies

  1. Theano
  2. Keras
  3. Optional: CUDA Toolkit for GPU programming.

Data

In order to reproduce the results reported in the paper, you will need

  1. The SemEval 2015 Twitter sentiment analysis datasets, as described in this paper.
    • The data is available in the data/txt folder. Unfortunately, the text content is not available due to Twitter policy. You need to replace "content" with the real tweets.
    • You can preprocss the raw tweets using (tweet = normalizeTextForSentiment(tokenizeRawTweetText(tweet), True)), which can be found in twokenize.py.
  2. The pretrained word embeddings (don't right click the link---use left click and Save link As...). You can save the file in data/word_embeddings.
  3. The pretrained author embeddings, which are available in data/author_embeddings.

Reproduce results

Great, now you are ready to reproduce the results

  1. Prepare the data, and generate the required data file semeval.pkl (available here)

    python process_data.py data/word_embeddings/struc_skip_600.txt \
                           data/semeval.pkl \
                           data/txt/train_2013.txt \
                           data/txt/dev_2013.txt \
                           data/txt/test_2013.txt \
                           data/txt/test_2014.txt \
                           data/txt/test_2015.txt 
    
  2. Reproduce CNN baseline results

    python cnn_baseline.py data/semeval.pkl 
    
  3. Reproduce mixture of experts baseline results

    python mixture_expert.py data/semeval.pkl 
    
  4. Reproduce concatenation baseline results

    python concat_baseline.py data/semeval.pkl data/author_embeddings/retweet.emb
    
  5. Reproduce SOCIAL ATTENTION results

    python social_attention.py data/semeval.pkl data/author_embeddings/retweet.emb
    
  6. Run with pre-trained model (Test13 F1: 71.7 Test14 F1: 75.6 Test15 F1: 66.8 Average: 71.4)

    python run_social_attention.py test data/semeval.pkl data/author_embeddings/retweet.emb model/social_attention_model.h5
    

About

Code for the TACL paper "Overcoming Language Variation in Sentiment Analysis with Social Attention"


Languages

Language:Python 100.0%