Think Like a Product Manager: Straightforward frameworks... by Eleanor Stribling
Published October 25, 2019
This video features Eleanor Stribling at DjangoCon US 2018 in San Diego, California, USA.
DjangoCon US 2018 - A Bossy Sort of Voice: Uncovering gender bias in Harry Potter with Python by Eleanor Stribling
The Harry Potter series is an incredibly popular franchise that shaped a generation, but it’s also been critiqued in the media and academics for its sometimes sexist portrayal of female characters. This talk uses Natural Language Processing techniques and Python to do the first quantitative analysis of gender bias in the language used to describe women and girls in the series, with a focus on Hermione Granger, the unsung hero of the story. Attendees will see techniques for reading and parsing large text files, leveraging grammatical rules to isolate the right words for the analysis, and data visualization techniques, using Python, the Natural Language Processing Toolkit (NLTK), and Matplotlib. After the talk, the audience will be able to get started on using the “magic” of programming to isolate biased language in any piece of text.
This talk was presented at: https://2018.djangocon.us/talk/a-bossy-sort-of-voice-uncovering-gender/
LINKS:
Follow Eleanor Stribling 👇
On Twitter: https://twitter.com/eleanorstrib
Official homepage: http://eleanorstrib.com
Follow DjangCon US 👇
https://twitter.com/djangocon
Follow DEFNA 👇
https://twitter.com/defnado
https://www.defna.org/
Eleanor Stribling examines gendered language in the Harry Potter books, focusing on how J. K. Rowling’s narration describes Hermione compared with Harry and Ron. Using Python and natural-language-processing tools, she extracts narration, identifies character mentions, and analyzes nearby verbs and adverbs while deliberately using a conservative method. Hermione is associated with words such as “bossy,” “shrill,” “squeaked,” and “squealing,” even though she is also a capable, conscientious, and courageous character; Harry’s distinctive language is more internal, while Ron’s reflects his grumbling personality. Stribling argues that such coded language can reproduce gender bias without conscious intent, and asks audiences to read beloved media critically and notice how similar words are applied to women, people of color, and other marginalized groups.
Summarised automatically from the transcript.
Automatically transcribed, so expect mistakes in names and technical terms.
Speaker 1: Hi everyone, thanks for coming to this talk. I know five o'clock is late and it's been a long day. I want to preface everything by saying I am not going to show you a bunch of code. I'm going to talk more about how I transform data So I'm going to do it without showing you any code. If you want code though, you can go to that URL and there you'll find a GitHub repo with a Jupyter Notebook that walks through all of this stuff. So if you really want to see some code at 5 p. m. on a Monday, feel free. So this talk is sort of near and dear to my heart because it rose out of something that was happening in both my personal and professional life. So my professional life is I'm right now a group product manager at Zendesk in San Francisco. I've been in tech in the Bay Area for about 10 years, most
Speaker 1: of that as a product manager, but pretty much the whole time I've been in a leadership role at tech companies that varied from teeny tiny startups to really big tech companies that you've definitely heard of And the common thread though throughout my entire experience was what a lot of women experience, which is just kind of little tiny bits of disrespect all the time. And they were usually in the form of very subtle, very coded language. And this has always bothered me. I love my work. I love what I do. That's why I still do it. But it's hard to take and it does wear on you. So while that was happening, um some significant things happened in my personal life. Um among them I had some kids. And one year my son, who is extremely into books and reading,
Speaker 1: got Harry Potter and the Philosopher's Stone as a Christmas gift And this came from my sister-in-law who loves Harry Potter, has read every one about ten times, and insisted that this was great for him. I didn't really know much about it. I sort of missed it being part of the Star Wars generation. And so I was didn't really know much about it. Honestly, I'd seen the movies. I think I fell asleep in number five at one point. So yeah, I had a very vague understanding of what Harry Potter was, but you know, I thought I'd give it a try, she would know And for those of you who aren't familiar, it's a series of books and it's really a franchise now of a lot of other things. But originally it was a series of seven books And it's about this kid named Harry Potter, and it follows him through ages 11 to 17 as he attends this boarding school in Britain called Hogwarts, where he learns how to be a wizard.
Speaker 1: And he meets up with other young people going through that same process. So like going through puberty and learning how to do magic, which is a horrible combination of things. But I could not have entrusted that. But at the same time that this is happening, uh Lord Voldemort, who is like a super, super evil guy Who wants to take over the world, reappears after everyone totally thought he was dead and thought that Harry was the only person who ever faced him and survived. So that's the premise of the books. So it sounds a little bit scary for a four-year-old, but I was like, okay, you know, I guess we can give this a shot. So we started with Philosopher's Stone. And one of the things I noticed about This book, um, which was really interesting was even though everyone told me about how much I would love Hermione, who's one of Harry's friends, he's got two friends, Ron and Hermione, and they're in all the books they
Speaker 1: help him out with stuff all the time, um even though Harry's the center, they're really important characters. And one thing that I found very striking about it was I really felt like the books could have been about Hermione because she's the one who's got everything under control. She works really hard at school. She studies, she applies herself. She's really like she's conscientious. She cares about other living things to a really large degree. And I found this this graphic which I thought really encapsulated how I felt. What if these books were actually about Hermione? My favorite is Hermione makes two useless friends. That was my favorite one. These are great, by the way, if you get a chance to read them all, the slides are online. But one thing that was really unfortunate to me, and this is where my personal and professional sort of situations sort of collided, wasn't how Hermione
Speaker 1: was described. So the title of this talk is A Bossy Sort of Voice, and that's taken from the very first time Hermione is introduced by J. K. Rowling, who's the writer of the Harry Potter series. She had a bossy sort of voice. before she's even named. And to me that really kind of cut because growing up in the 80s and 90s, being called bossy was not a good thing and it was almost always applied to girls. and frequently to me. So that kind of hurt. And as I read it more, these are just two examples I could sort of think of off the top of my head. I kept seeing these things like bossy know it all, shrill voice to describe women and girls. So that was kind of a letdown because I really wanted to read this to my son to get him thinking about strong female characters and characters who didn't look like him generally.
Speaker 1: So I decided to investigate this and try to turn it into a conference talk. I'd like to say that even though I was part of the Star Wars generation, I was not unaware of how popular the series was. So when I would tell people as I did this project, I'm doing a conference talk about sexism in Harry Potter, the reaction was pretty much this every single time, like, how dare you? So that was a little bit disconcerting to anger the Harry Potter fan group. But this wasn't just me. Other people have noticed this. two. And um being, you know, kind of maybe a little bit like Hermione, I did some research at the library and um I found a bunch of books that whoops that uh cover this
Speaker 1: in uh some detail. Whoops. Little slide mount function there They cover this in some detail. And these chapters of these books are written by literary scholars, and they write about a lot of really interesting things. including gender bias in Harry Potter, including race in Harry Potter, magic culture in Harry Potter. So a lot of really cool topics. So if you're interested, I recommend you check it out. But one thing I noticed is they approach it all always very much like literary scholars do, which is talking about specific situations, talking about how those situations are woven into a bigger fabric and that makes a ton of sense, but one thing that I didn't really see much of was really analyzing the language that Rowling
Speaker 1: used to describe the female characters. It happened, but it wasn't done in kind of a broad programmatic way. And this kind of makes sense. There were seven books at the time, and altogether they have one about 1. 1 million words, like actually more than that. So this is not something you know your average you know literature professor is going to do. So I thought this was a great opportunity to apply some code to the problem. Another way personal professional kind of collided on this one So I want to talk next about what I actually did, how I went about this. Because I think this is actually more so than the code, really the most interesting part of the project. So the toolbox I used, pretty straightforward, Python, Jupyter Notebook, which you'll see in the GitHub repo I used the natural language processing toolkit and I didn't even use the most powerful parts of it.
Speaker 1: I used some pretty sort of standard functions in it that were incredibly useful though. And then I'll use PyPlot because what is a textual analysis without a lot of word clouds? So brace yourself for some word clouds coming right up. So figuring out how to approach this was hard because if you've read the Harry Potter books, there are seven of them. They span like seven years. Um and there are a lot of characters. So I was kind of like, well, you know, what do I do? I went through this whole process of trying to figure out how do I find all the female characters and I was on all these wikis trying to like pull date off. It was sort of a mess. Um but it then I decided to simplify a little bit. Um and to look at as my hypothesis that Hermione was going to be described by J. K. Rowling in words that are used to describe women in a pejorative way
Speaker 1: or highlight really sort of effeminate qualities in a not so great way. So that that was what I decided to do, and I decided to compare her to Harry and Ron. And the main reason I did this was that she's mentioned quite a bit as are Harry and Ron. And so even though she's mentioned the least of the three Not surprisingly, right? Um, she is mentioned in every single book and she matures with them and they're all about the same age. So I thought, you know, that's pretty pretty good comparison. What did this mean for my analysis? Well, first of all, it meant I wanted to focus on narration, not dialogue. So I didn't really care if there was a sexist character. What I cared about was how the narrator who's supposed to be a little bit objective, um, how the narrator was uh was uh describing her money. Then I wanted to look at actions rather than uh
Speaker 1: than uh descriptions because there aren't really that many descriptions first of all and it's really hard to parse some of them and attribute the correct um adjectives to the right character So I decided that I would concentrate only in verbs and adverbs. I'll talk more about this a little bit later. And then I decided I only wanted to compare the three principal characters, like I mentioned, only Hermione versus Harry and Ron. So there were three steps I used to analyze the text. And once again, you can go look at the code if you really, really, really want to look at code right now. First, I had to get the text into a format that Python could use Then I had to isolate the parts of the text I wanted to analyze, and then I wanted to find and summarize the relevant words within that So to illustrate that, instead of using code, I'm going to use an actual text snippet.
Speaker 1: So this is, if you're not familiar with the Harry Potter books and you've read them multiple times, which I don't know, maybe some of you have. This is from the Philosopher's Stone, and this is uh shortly after that first introduction of Hermione. I mentioned when all three of the principal characters were on the train. And the reason I used this one was that it's got both dialogue and narration, and it mentions all three of the characters. So I think it's a pretty good illustration of what I did. So here's the text. This these first steps are really straightforward. I just read it into Python using the open function. It's a giant string now. And then what I did was I used the word tokenize function in NLTK, which basically just takes that giant string of text that Python is now able to grok, takes that string of text and breaks it up into essentially a
Speaker 1: giant list. of words and punctuation. And it looks like that. Now if you've done text processing yourself, you might wonder, well, hang on, don't you want to take all the punctuation and the stop words out? Punctuation would be things like the quotation marks, the commas, etc. And the stop words are common English language words. And the answer is no, because the punctuation and the order of the words And the proximity of the words is was actually really important for my analysis. So I'll show you why in a second, but that's why I didn't do that. First order of business was remember I want narration. I want to see how the subjective narrator describes Hermione in ways that are different from Harry and Ron. So one thing I learn whenever I do text processing is English is a really, really inconsistent language. But one thing that is consistent about it
Speaker 1: and is consistent in J. K. Rowling's novels is when characters speak Their dialog is in quotation marks. So I wrote a function to pull everything between quotation marks and stick it into this list of dialogue. So then I just have the dialogue from that snippet. And then another list of narrations. So every single narrative passage gets its own little sublist. So that was the first step. And remember, I want to focus on the narration. So from here on in, discarding dialogue, looking only at narration. The next thing I did was look for mentions of Harry, Rod, and Hermione in the narration. And I made a dictionary where the key is the character name and the value was a list of all the times they were mentioned. Now one thing you might be wondering is, well, what did you do if it if it had something like
Speaker 1: she said angrily? How did you handle that? I didn't. Just because it was harder to tell who that she might have been referring to. So what I decided to do was just get rid of that and only use the instances where I was really, really sure that those words applied to that protagonist So just to be extra extra sure. So those are the keys with the character names. So then what I did was I used the position tag function in NLTK. to uh identify the part of speech that each word represented. So you can see that here. So you've got if you look at the hairy key. You can see Harry and then NNP. So NNP is is a tag to represent the part of speech. NNP is noun. And then you've got looked, which is a verb. So and so on.
Speaker 1: So this basically let me isolate the important nouns and the verbs and adverbs around them, which again is what I wanted to look at. So this is a little bit of a sidebar, but this was a really important part of the project, and I think another reason why the process was kind of more interesting than the code in a lot of ways. So I had to look at patterns in language in order to find the right words, right? So there are a few patterns that J. K. Rowling and most novelists use in putting verbs and adverbs around character names. So one of them is verb noun, yelled Harry. Another one is verb-noun adverb, so said Harry happily. Another one is noun verb, Harry saw. Another one is
Speaker 1: noun, adverb, verb. This is actually harder than it might sound. And like Harry whispered softly. So those are the patterns that I've I found. And that makes sense. They're very common patterns in English. So how I translated that into code and what I did with it? Well, what I did was I wrote a function that basically looked around Look for these sequences here. These are all noun, verb, or verb, noun, but just it's the simple example, but to give you to give you some some context for it. So basically I looked for those patterns that you can see there And then I made a dictionary where the key is the character name and the values were all of those words that I found that were verbs or adverbs. So in this particular example, you can see that
Speaker 1: said is used by both Harry and Hermione. So that would mean in the next step where I basically got rid of all of those repeated words the that said would be removed from both Hermione and Harry's list. So what you learn from this dictionary is only Harry used the word look or only looked was used to describe Harry. Muttered was only used to describe Ron. Sounds about right if you know the books And there is no unique verb or adverb there for Hermione. So that's the process I went through in a nutshell. So now the findings. So get ready for some more clouds. So what one of the first things I did was look at how Hermione is described in each book with words that are only used to describe her. So this line has all the books on it.
Speaker 1: And then when you look at all the word clouds, it gives you a very high-level idea of what's going on here. So some of the words are totally innocuous, like earnestly or something like that. But you can see say in book one, you've got shriek squeaked and timidly are like the first things you see, like right there. on the uh on the left. And it really depends on the book, but there are definitely words in each one that are a little bit, uh, there's a lot of squealing. Just so you know. And I I spent a lot of time around little boys growing up. Um I babysat little boys. Eleven-year-old boys squeal and shriek a lot. So I don't really know why they weren't at least in the earlier books. Um so as I mentioned before, one of the things I wanted to do was compare Hermione to Harry and Ron. So you might be thinking, well, okay, you know, some of these words just on first pass
Speaker 1: look a little bit off, but You know, what about Harry and Ron? Like you didn't show us the words that were used to describe only them. I have a slide for that. Um so I made this table to explain the results. Across the top you've got the book numbers and then down the side you've got Harry, Ron, and Herman. And so what this shows is the word that was used to describe them exclusively in the book that the column represents, and then in the frequency. So you might be thinking here the frequency is quite low, and that's because I was really conservative with how I did this. I was only looking for verbs and adverbs, and only in cases where they were located around a protagonist's like actual name. So it's a very kind of conservative sample. But here are a couple things that stood out to me. For Harry, um, I think this makes sense.
Speaker 1: Rowling uses him as the lens. for the narrative. So a lot of the words that are used only to talk about him are like thought and wondered and very sort of internal concepts. Not all, but it's pretty different than the other characters. With Ron, if you're again if you're familiar with the books, Ron's a real grouch, like more so than most teenage boys. And he uh there's a lot of stuff that's exclusive to him that's like groaning and moaning and complaining and being gruff. stuff like that, which really does fit Ron, right? Don't find me on that. It's true. So Hermione, what emerges for her? Well so going back to what I said at the beginning, I really thought Hermione was a great character. She was so strong, she leads resistance, she comes up with a whole resistance and makes Harry the leader of it, which I thought was a little bit weird.
Speaker 1: But anyway. I thought she'd be used with very heroic terms, and a lot of them are neutral, but there are quite a few in there that echo what I said earlier. Squeaking. Squealing. In book seven I highlighted that because I thought it was kind of especially unfortunate. She's got squeaked shrilly breathed and breathless and squealing and you know I was just sort of like in that book she does so many great things and it was just so unfortunate to see that. Um So what do I want you to take from this? You can totally go out and analyze Harry Potter by yourself and tell me how I'm wrong if you want. I dare you. But what I would really like you to take from this is what I mentioned at the very beginning about coded language and how people who
Speaker 1: work in tech and beyond uh really do deal with this all the time. And they're very subtle language cues that I think sometimes we don't even notice. I sincerely think J. K. Rowling did not notice that she was doing this. I really do. I I don't I don't think she was trying to do this. But I think that it's so innate to a lot of us. It's just how we sort of think um that um that it happens. And so what I would ask is that you look for words like the ones on the screen to describe women and people of color, people based on their sexual preference, and just be critical of them. And really be thoughtful when you're when you're consuming media, especially media that you love. Things like Harry Potter, which I know a lot of people love, but it's not perfect. And I think we need to kind of keep that in mind, especially when we're we're reading it to our kids.
Speaker 1: I definitely do. So thank you for coming to this talk. I really do appreciate once again that you stay till 5 p. m. That's really awesome. I do a lot of projects around literature and trying to use programming to understand literature better. I come from a literature family. Both my parents were college English professors, which It's probably a whole other talk. But yeah, so I've I've really enjoyed doing this. I did a different presentation for PyCon about Gothic literature. So if you're interested in this area, I haven't, I feel like, really even scratched the surface of some of the tools that could be used to help folks out who are in those fields. humanities, social sciences, journalism, all that stuff if you're interested in the same sort of general realm, please do look me up on Twitter.
Speaker 1: So thank you very much.
Speaker 2: I just happened to be here, but I absolutely love this talk. Oh thank you. Uh I'm kind of I've just personally started doing a lot more writing myself and been thinking about words and their meanings because and some of their preconceived notions. And as in I did a lightning talk earlier and the Like when I kind of think of when I say, here's who I am, it's like I have EDD and I have and I'm crazy. These are two words that were like crazy is such a ha been a word that's like stigma and there's been mental disorders in my family that have been labeled things and they're cons you know, they have preconceived notions as being bad and where it's like
Speaker 2: Now I just see these words as they describe me, but I've changed their definition to me. So where I'm like, hey, I'm crazy, but I'm accepting of that and I use it to do crazy awesome things And my ADD means that I don't really feel like doing that right now, so I'm gonna do what I feel like doing and it charges me up and it lets me do something else. Like all of a sudden when I procrastinated one time At work. I don't know, my boss is in here. Um, I was writing, got the flow, just purged out this stuff in like half an hour as fast as I could type, just type it away. Before he knew it, then I like got into work and got got onto my well, I was at work, but I was then doing my work work and I was in the flow and helped me continue that flow into my work
Speaker 2: And and so these are just sorry, this is a long question. Sorry. All right. So words, preconceived notions and how they change in through time and our definition of things through time and our culture since society has preconceived notions of those words. So mm answer how you that whatever you want.
Speaker 1: Well so that's interesting. So thanks for calling out the the health and and ableism generally. I think that's important. one too. So so yeah, so I think that one one bit of pushback I guess that I've had on this was that um a few years back, maybe three years ago, there was this campaign to sort of reclaim BOSI as a term. And so I think you could maybe look at that lens, but I think what's really important. One thing I've learned doing this type of work, like looking at different literature from different eras. is you do have to put the lens of the the time that it was written on it a little bit. So even though BOSI may not feel pejorative to somebody now. Yeah, exactly. Um yeah, even if it's reclaimed it in the context of the time it wasn't meant as a compliment. Um so that I think that that's that's really important.
Speaker 1: But I do also think, I mean, there's nothing inherently bad about squealing. It's just the way that the context in which that word exists is so negative.
Speaker 3: So first of all, awesome talk. This was extremely cool And I dug it. Uh my question is, would it be easy to apply this process to non-protagonist characters? And the reason I'm asking is because it'd be super cool to see if these trends were consistent among multiple female characters, or instead if it was super specific to the characterization of Hermione. Mm-hmm.
Speaker 1: Yeah, that's a great question. So with the code as it exists now, no, it's not hard. Really all you have to change is the names of the protagonists, and then you're good. Um there's nothing built into the code about what is what is negative or pejorative. So it's really up for some interpretation. But yeah, you could add female characters, you could do good versus evil kind of a comparison. Could be really interesting too. Um yeah it would be very, very easy to do that with any characters. Do you plan to? Sure. Yeah, I I get asked that actually quite a bit. And like for example, if J. K. Rowling is more sexist or less sexist than some other author, you know, if if I can compare it that way. So yeah, you totally could. Haven't got around to yet, maybe one day. Thank you. Thanks for
She used Python and natural-language processing to examine narration rather than dialogue, isolate mentions of Harry, Ron, and Hermione, and compare the verbs and adverbs associated with each character. She used a deliberately conservative sample, keeping only words found near the characters’ names.
Discussed at 7:25Hermione is repeatedly associated with words such as “squeaked,” “shrieked,” “squealed,” “shrilly,” “breathless,” and “timidly.” Stribling argues that these descriptions contrast with Hermione’s courageous actions and reflect coded language often applied negatively to women and girls.
Discussed at 15:24Harry is commonly described through internal, viewpoint-related words such as “thought” and “wondered,” while Ron is associated with groaning, moaning, complaining, and gruffness. Hermione has some neutral or heroic associations, but also a notable set of feminine-coded words involving squealing and shrillness.
Discussed at 16:37Yes. The existing code can be adapted simply by changing the character names, and it could compare additional female characters, good and evil characters, or even different authors. The method does not automatically determine which words are pejorative, so that interpretation still has to be supplied by the researcher.
Discussed at 23:01Note: We understand that names change, people change, and bodies change. We respect each individual's journey and privacy. If you have any concerns about a video or need us to remove content, please don't hesitate to contact us. We will handle your request with care and promptly address any issues.
Published July 15, 2026
Published July 15, 2026
Published July 15, 2026
Published July 15, 2026
Published July 15, 2026
Published July 14, 2026