<commit_before>---
layout:     post
title:      Sentiment of the City
date:       2018-01-02
summary:    
categories: sotc
---

Sentiment analysis is common way to assess emotion in text. Companies use it to understand how customers [feel about their products](https://ymedialabs.com/google-sentiment-analysis-api/) and medical researchers . In the politic science, researchers have used sentiment analysis to assess the [tenor of parliamentary debate](https://link.springer.com/chapter/10.1007/978-3-319-06826-8_4) and measure [response to State of the Union speeches](https://www.aclweb.org/anthology/P/P12/P12-3.pdf#page=127) on Twitter. 

I wanted to use this approach and my State of the City corpus to answer two questions:

1. In 2017, which mayors gave the most positive and negative speeches?
2. How does sentiment change over the course of a speech? Are there clear positive of negative sections?

If you're just interested in the answers, scroll down to the charts below. If you're interested in the methodology, here's the R code:


```R<commit_msg>updating header<commit_after>---
layout:     post
title:      Sentiment of the City
date:       2018-01-02
summary:    Analyzing how mayors use sentiment in State of the City speeches
categories: sotc
---

Sentiment analysis is common way to assess emotion in text. Companies use it to understand how customers [feel about their products](https://ymedialabs.com/google-sentiment-analysis-api/) and medical researchers . In the politic science, researchers have used sentiment analysis to assess the [tenor of parliamentary debate](https://link.springer.com/chapter/10.1007/978-3-319-06826-8_4) and measure [response to State of the Union speeches](https://www.aclweb.org/anthology/P/P12/P12-3.pdf#page=127) on Twitter. 

I wanted to use this approach and my State of the City corpus to answer two questions:

1. In 2017, which mayors gave the most positive and negative speeches?
2. How does sentiment change over the course of a speech? Are there clear positive of negative sections?

If you're just interested in the answers, scroll down to the charts below. If you're interested in the methodology, here's the R code:


```R
{'fraction_non_alphanumeric': 0.07678244972577697, 'fraction_numerical': 0.038391224862888484, 'mean_word_length': 4.162735849056604, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '120875', 'n_tokens_mistral': 659, 'n_tokens_neox': 573, 'n_words': 281}