The cast of “Star Wars: The Last Jedi” is seen at the film’s premiere in Los Angeles on Dec. 9. (Jesse Grant/Getty Images for Disney)

America’s most iconic movie franchise, Star Wars, has been denounced by the alt-right for unflattering representation of men, casting to pander to diversity and leftist moralizing. That discussion of gender and race in Star Wars went mainstream after the December 2017 release of “The Last Jedi.” The movie has the franchise’s first nonwhite female lead, portrays an elderly Luke Skywalker confronting his failures and leaves the Jedi order in the hands of a young woman.

In June, harassment prompted Kelly Marie Tran, a Vietnamese American actress who’s in the film, to delete her Instagram account. In August, Tran wrote in the New York Times that online commenters “seemed to confirm what growing up as a woman and a person of color already taught me: that I belonged in margins and spaces, valid only as a minor character in their lives and stories.”

How common is such harassment?

In my research, I have investigated this phenomenon on Twitter, where offensive language and hate speech have a modest but clear presence — not because of automated accounts (“bots”) but because of humans. People use degrading language more frequently when they talk about women and minorities and when they talk to female fans.

Here’s how I did my research

I collected thousands of tweets from Star Wars fans and used computer algorithms to characterize fan conversations. With tools developed at Cornell University, I examined tweets for positive or negative attitudes, “offensive language’’ (profanity and belligerence), and “hate speech,’’ which includes ethnic, misogynistic, and homophobic slurs, as well as threats of violence. Cornell’s algorithm also classifies extreme slurs against political and ideological groups as hate speech.

I found that in a keyword search for “Star Wars” or “The Last Jedi” (including variants and abbreviations), about 6 percent of tweets used offensive language. I removed false positives in which the algorithm misunderstood the context. On the other hand, the algorithm cannot detect politely worded attacks, so it’s possible that it underestimates abuse. Nor could I count tweets deleted by their author or for violation of community standards, which disappear from Twitter’s archives. (Twitter’s data suggest about 5 percent of tweets are deleted.)

Hate speech is rarer than offensive language, appearing in about one tweet out of 100. However, this is likely an underestimate of the amount of posted hate speech, since most hate speech is subject to deletion for violating community standards.

Such tweets are not popular. Tweets with offensive language or hate speech are from accounts that have fewer followers than average. Further, these posts receive fewer endorsements (“likes” or “favorites”), retweets, or replies than more neutral posts.

What about bots?

Some observers have suggested that automated Twitter “bots” are responsible for anger or harassment in Star Wars Twitter. But I find no evidence for this. Using Botometer, a bot detector from the University of Indiana, I estimate that just 4.4 percent of Star Wars-related tweets are generated by bots. Tweets by bots contained offensive language less often than tweets by humans: 3 percent instead of 6 percent. Bots produced no hate speech tweets.

Identity politics influences abuse

I wanted to know how people tweet about Star Wars in general — and how that differs from how they tweet about women and minorities in Star WarsI compared general Star Wars-related tweets to tweets about Kelly Marie Tran, the actress harassed on Instagram, or about Rose Tico, her “Last Jedi” character. The proportion of tweets with offensive language doubled from 6 to 12 percent — and hate speech jumped 60 percent, rising from 1.1 percent to 1.8 percent of all tweets.

That’s not because Rose Tico is an unpopular character. The algorithm measures abuse, not dislike. The difference in abusive language is even larger if we compare only negative posts. Fans complain about Star Wars’ first nonwhite female lead in more degrading language than they complain about other parts of the franchise.

It is not inherently racist or sexist to dislike Star Wars or “The Last Jedi.” The point of the comparison is that tweeting about these movies turns belligerent when it comes to race and gender.

Female fans are harassed more

Twitter abuse is directed at female fans more often than male fans. To examine whether this was so, I collected and analyzed tweets sent to fan podcasts. I looked at 37 fan accounts run by men, and 26 by women. (Fans’ other identities, like race or sexuality, were mostly unclear.) The fan podcasters are not celebrities or Lucasfilm employees.

I found that male fans received offensively worded tweets about as often as female fans. About 8 percent of tweets sent to male fans used offensive language, compared with 9 percent of tweets directed at female fans — a negligible difference. The difference in hate speech was more dramatic. In tweets to male podcasters, one in 450 tweets contained hate speech. But for female podcasters, about one in 280 tweets contained hate speech.

Men will underestimate the amount of abusive posting on Twitter if they use themselves as the point of reference.

Offensive tweets and hate speech did not come only from those identified as politically right wing. Most posts are too generic to infer political views. But I did find that such belligerence also comes from the cultural left. Female podcasters, in particular, are attacked for not supporting diversity and gender equality strongly enough.

A divided popular culture

Most people who tweet about Star Wars are congenial and skeptical about “trolls.” But as with other cultural icons — whether it’s an all-female “Ghostbusters” or NFL players kneeling during the national anthem — a significant few respond with anger and hate when gender and race expectations change. We know that from the numbers.

Bethany Lacina is an associate professor of political science at the University of Rochester.