<p><strong>Previously in this series</strong></p>
<ul><li><a href="http://varianceexplained.org/r/tidytext-plots/">Examining the arc of 100,000 stories</a></li>
</ul><p>I was fascinated by my colleague <a href="http://juliasilge.com/">Julia Silge’s</a> recent blog post on <a href="http://juliasilge.com/blog/Gender-Pronouns/">what verbs tend to occur after “he” or “she” in several novels</a>, and what they might imply about gender roles within fictional work. This made me wonder what trends could be found across a larger dataset of stories.</p>
<p>Mark Riedl’s <a href="http://varianceexplained.org/r/tidytext-plots/">Wikipedia plots dataset</a> that I examined in yesterday’s post offers a great opportunity to analyze this question. The dataset contains over 100,000 descriptions of plots from films, novels, TV shows, and video games. The stories span centuries and come from tens of thousands of authors, but the descriptions are written by a modern audience, which means we can quantify gender roles across a wide variety of genres. Since the dataset contains plot descriptions rather than primary sources, it’s also more about what <strong>happens</strong> at than how an author describes the work: we’re less likely to see “thinks” or “says”, but more likely to see “shoots” or “escapes”.</p>
<p>As I usually do for text analysis, I’ll be using the <a href="https://github.com/juliasilge/tidytext">tidytext package</a> Julia and I developed last year. To learn more about analyzing datasets like this, see our online book <a href="http://tidytextmining.com/">Text Mining with R: A Tidy Approach</a>, soon to be <a href="https://www.amazon.com/Text-Mining-R-tidy-approach/dp/1491981652">published by O’Reilly</a>. I’ll provide code for the text mining sections so you can follow along. I don’t show the code for most of the visualizations to keep the post concise, but as with all of my posts the code can be found <a href="https://github.com/dgrtwo/dgrtwo.github.com/tree/master/_R/2017-04-27-tidytext-gender-plots.Rmd">here on GitHub</a>.</p>
<h3>Setup</h3>
<p>We’d start with the same code from <a href="http://varianceexplained.org/r/tidytext-plots/">the last post</a>, that read in the <code>plot_text</code> variable from the raw dataset. Just as Julia did, we then tokenize the text into <a href="http://tidytextmining.com/ngrams.html">bigrams</a>, or consecutive pairs of words, with the tidytext package, then filter for cases where a word occurred after “he” or “she”.<a href="http://varianceexplained.org/#fn:binary">1</a></p>
<pre><code><span>library</span><span>(</span><span>dplyr</span><span>)</span><span>
</span><span>library</span><span>(</span><span>tidytext</span><span>)</span><span>
</span><span>bigrams</span><span> </span><span>&lt;-</span><span> </span><span>plot_text</span><span> </span><span>%>%</span><span>
</span><span>unnest_tokens</span><span>(</span><span>bigram</span><span>,</span><span> </span><span>text</span><span>,</span><span> </span><span>token</span><span> </span><span>=</span><span> </span><span>&quot;ngrams&quot;</span><span>,</span><span> </span><span>n</span><span> </span><span>=</span><span> </span><span>2</span><span>,</span><span> </span><span>collapse</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>)</span><span>
</span><span>bigrams_separated</span><span> </span><span>&lt;-</span><span> </span><span>bigrams</span><span> </span><span>%>%</span><span>
</span><span>separate</span><span>(</span><span>bigram</span><span>,</span><span> </span><span>c</span><span>(</span><span>&quot;word1&quot;</span><span>,</span><span> </span><span>&quot;word2&quot;</span><span>),</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot; &quot;</span><span>)</span></code></pre><pre><code><span>he_she_words</span><span> </span><span>&lt;-</span><span> </span><span>bigrams_separated</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>word1</span><span> </span><span>%in%</span><span> </span><span>c</span><span>(</span><span>&quot;he&quot;</span><span>,</span><span> </span><span>&quot;she&quot;</span><span>))</span><span>
</span><span>he_she_words</span></code></pre><pre><code>## # A tibble: 797,388 × 4
##    story_number                      title word1      word2
##           &lt;dbl>                      &lt;chr> &lt;chr>      &lt;chr>
## 1             1                Animal Farm    he     refers
## 2             1                Animal Farm    he    accuses
## 3             1                Animal Farm    he  collapses
## 4             1                Animal Farm    he celebrates
## 5             1                Animal Farm    he  abolishes
## 6             2 A Clockwork Orange (novel)    he         is
## 7             2 A Clockwork Orange (novel)    he  describes
## 8             2 A Clockwork Orange (novel)    he      meets
## 9             2 A Clockwork Orange (novel)    he    invites
## 10            2 A Clockwork Orange (novel)    he      drugs
## # ... with 797,378 more rows</code></pre><p>For example, we see the plot description for “Animal Farm” has five uses of a verb after “he”, such as “he refers” and “he accuses”. (Note that throughout this post I’ll refer to these after-pronoun words as as “verbs” since the vast majority are, but some are conjunctions like “and” or adjectives like “quickly”).</p>
<h3>Gender-associated verbs</h3>
<p>Which words were most shifted towards occurring after “he” or “she”? We’ll filter for words that appeared at least 200 times.</p>
<pre><code><span>he_she_counts</span><span> </span><span>&lt;-</span><span> </span><span>he_she_words</span><span> </span><span>%>%</span><span>
</span><span>count</span><span>(</span><span>word1</span><span>,</span><span> </span><span>word2</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>spread</span><span>(</span><span>word1</span><span>,</span><span> </span><span>n</span><span>,</span><span> </span><span>fill</span><span> </span><span>=</span><span> </span><span>0</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>total</span><span> </span><span>=</span><span> </span><span>he</span><span> </span><span>+</span><span> </span><span>she</span><span>,</span><span>
</span><span>he</span><span> </span><span>=</span><span> </span><span>(</span><span>he</span><span> </span><span>+</span><span> </span><span>1</span><span>)</span><span> </span><span>/</span><span> </span><span>sum</span><span>(</span><span>he</span><span> </span><span>+</span><span> </span><span>1</span><span>),</span><span>
</span><span>she</span><span> </span><span>=</span><span> </span><span>(</span><span>she</span><span> </span><span>+</span><span> </span><span>1</span><span>)</span><span> </span><span>/</span><span> </span><span>sum</span><span>(</span><span>she</span><span> </span><span>+</span><span> </span><span>1</span><span>),</span><span>
</span><span>log_ratio</span><span> </span><span>=</span><span> </span><span>log2</span><span>(</span><span>she</span><span> </span><span>/</span><span> </span><span>he</span><span>),</span><span>
</span><span>abs_ratio</span><span> </span><span>=</span><span> </span><span>abs</span><span>(</span><span>log_ratio</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>arrange</span><span>(</span><span>desc</span><span>(</span><span>log_ratio</span><span>))</span></code></pre><p>This can be visualized in a bar plot of the most skewed words.<a href="http://varianceexplained.org/#fn:himself">2</a></p>
<p></p>
<p>I think this paints a somewhat dark picture of gender roles within typical story plots. Women are more likely to be in the role of victims- “she screams”, “she cries”, or “she pleads.” Men tend to be the aggressor: “he kidnaps” or “he beats”. Not all male-oriented terms are negative- many, like “he saves”/”he rescues” are distinctly positive- but almost all are active rather than receptive.</p>
<p>We could alternatively visualize the data by comparing the total number of words to the difference in association with “he” and “she”. This helps find common words that show a large shift.</p>
<pre><code><span>he_she_counts</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>!</span><span>word2</span><span> </span><span>%in%</span><span> </span><span>c</span><span>(</span><span>&quot;himself&quot;</span><span>,</span><span> </span><span>&quot;herself&quot;</span><span>,</span><span> </span><span>&quot;she&quot;</span><span>),</span><span>
</span><span>total</span><span>>=</span><span> </span><span>100</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>total</span><span>,</span><span> </span><span>log_ratio</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_point</span><span>()</span><span> </span><span>+</span><span>
</span><span>scale_x_log10</span><span>(</span><span>breaks</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>100</span><span>,</span><span> </span><span>1000</span><span>,</span><span> </span><span>10000</span><span>,</span><span> </span><span>1e5</span><span>),</span><span>
</span><span>labels</span><span> </span><span>=</span><span> </span><span>comma_format</span><span>())</span><span> </span><span>+</span><span>
</span><span>geom_text</span><span>(</span><span>aes</span><span>(</span><span>label</span><span> </span><span>=</span><span> </span><span>word2</span><span>),</span><span> </span><span>vjust</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>hjust</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span>
</span><span>check_overlap</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span> </span><span>+</span><span>
</span><span>scale_y_continuous</span><span>(</span><span>breaks</span><span> </span><span>=</span><span> </span><span>seq</span><span>(</span><span>-2</span><span>,</span><span> </span><span>2</span><span>),</span><span>
</span><span>labels</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>'4X &quot;he&quot;'</span><span>,</span><span> </span><span>'2X &quot;he&quot;'</span><span>,</span><span> </span><span>&quot;Same&quot;</span><span>,</span><span> </span><span>'2X &quot;she&quot;'</span><span>,</span><span> </span><span>'4X &quot;she&quot;'</span><span>))</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>'Total uses after &quot;he&quot; or &quot;she&quot; (note log scale)'</span><span>,</span><span>
</span><span>y</span><span> </span><span>=</span><span> </span><span>'Relative uses after &quot;she&quot; to after &quot;he&quot;'</span><span>,</span><span>
</span><span>title</span><span> </span><span>=</span><span> </span><span>&quot;Gendered verbs: comparing frequency to pronoun shift&quot;</span><span>,</span><span>
</span><span>subtitle</span><span> </span><span>=</span><span> </span><span>&quot;Only words occurring at least 100 times after he/she. Overlapping labels were removed.&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>expand_limits</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>75</span><span>)</span></code></pre><p></p>
<p>There are a number of very common words (“is”, “has”, “was”) that occur equally often after “he” or “she”, but also some fairly common ones (“agrees”, “loves”, “tells”) that are shifted. “She accepts” and “He kills” are the two most shifted verbs that occurred at least a thousand times, as well as the most frequent words with more than a twofold shift.</p>
<h3>“Poison is a woman’s weapon”: terms related to violence</h3>
<p>Women in storylines are not always passive victims: the fact that the verb “stabs” is shifted towards female characters is interesting. What does the shift look like for other words related to violence or crime?</p>
<p></p>
<p>There’s an old stereotype (that’s appeared in works like Game of Thrones and Sherlock Holmes) that “poison is a woman’s weapon”, and this is supported in our analysis. Female characters are more likely to “poison”, “stab”, or “kick”; male characters are more likely to “beat”, “strangle”, or simply “murder” or “kill”. Men are moderately more likely to “steal”, but much more likely to “rob”.</p>
<p>It’s interesting to compare this to <a href="https://www.washingtonpost.com/news/wonk/wp/2015/05/07/poison-is-a-womans-weapon/">an analysis from the Washington Post of real murders in America</a>. Based on this text analysis, a fictional murderer is about 2.5X as likely to be male than female, but in America (and likely elsewhere) murderers are about 9X more likely to be male than female. This means female murderers may be overrepresented in fiction relative to reality.</p>
<p>The fact that men are only slightly more likely to “shoot” in fiction is also notable, since the article noted that men are considerably more likely to choose guns as a murder weapon than women are.</p>
<h3>Try it yourself</h3>
<p>This data shows a shift in what verbs are used after “he” and “she”, and therefore what roles male and female characters tend to have within stories. However, it’s only scratching the surface of the questions that can be examined with this data.</p>
<ul><li><strong>Is the shift stronger in some formats or genre than another?</strong> We could split the works into films, novels, and TV series, and ask whether these gender roles are equally strong in each.</li>
<li><strong>Is the shift different between male- and female- created works?</strong></li>
<li><strong>Has the difference changed over time</strong>? Some examination indicates the vast majority of these plots come from stories written in the last century, and most of them from the last few decades (not surprising since many are movies or television episodes, and since Wikipedia users are more likely to describe contemporary work).</li>
</ul><p>I’d also note that we could expand the analysis to include not only pronouns but first names (e.g. not only “she tells”, but “Mary tells” or “Susan tells”), which would probably improve the accuracy of the analysis.</p>
<p>Again, the full code for this post is available <a href="https://github.com/dgrtwo/dgrtwo.github.com/blob/master/_R/2017-04-27-tidytext-gender-plots.Rmd">here</a>, and I hope others explore this data more deeply.</p>
<div>
<ol><li>
<p>Gender is not a binary, so please note that this analysis is examining how the Wikipedia description’s author refers to the character. For example, we miss cases of <a href="https://en.wikipedia.org/wiki/Gender-neutral_language">singular they</a>, but it would be challenging to separate it from the more common plural. <a href="http://varianceexplained.org/#fnref:binary">↩</a></p>
</li>
<li>
<p>I’m also skipping the words “himself” and “herself”, which are the most gender-shifted words but aren’t interesting for our purposes. <a href="http://varianceexplained.org/#fnref:himself">↩</a></p>
</li>
</ol></div>