This analysis extends Gian’s Nov 3 text and sentiment analysis to all three weeks of Bluesky posts our group collected (search terms “movies” and “movie theatre”). We clean each week the same way, then compare:
Raw data folder (OneDrive): https://csub-my.sharepoint.com/:f:/g/personal/gabundo_csub_edu/IgBgnXdBaB24TbgeWsgMIZ2YAfEZfwjurryBxYUZr3sPKbQ?e=Xmcfdb
Files needed: movie-scrape-1.csv,
movie-scrape-2.csv and movie-scrape-3.csv in
the same folder as this .Rmd.
pkgs <- c("tidyverse", "tidytext", "plotly", "scales")
missing_pkgs <- pkgs[!pkgs %in% rownames(installed.packages())]
if (length(missing_pkgs) > 0) install.packages(missing_pkgs, repos = "https://cloud.r-project.org")
library(tidyverse) # dplyr, stringr, readr, lubridate, ggplot2
library(tidytext) # tokenizing, stop words, Bing lexicon, TF-IDF
library(plotly) # interactive chart
library(scales) # percent labels
Lexicons. Bing is built into tidytext.
AFINN and NRC are read from public GitHub copies of the same versions
textdata uses (AFINN-111 and NRC v0.92). Reading them
directly avoids textdata’s Yes/No download prompt, which
stops a knit. Each file is saved in a lexicons/ folder
after the first knit.
dir.create("lexicons", showWarnings = FALSE)
get_lex <- function(url, file) {
path <- file.path("lexicons", file)
if (!file.exists(path)) download.file(url, path, quiet = TRUE)
path
}
afinn <- read_tsv(get_lex("https://raw.githubusercontent.com/fnielsen/afinn/master/afinn/data/AFINN-111.txt",
"AFINN-111.txt"),
col_names = c("word", "value"), col_types = "cd", quote = "")
nrc <- read_tsv(get_lex("https://raw.githubusercontent.com/dinbav/LeXmo/master/NRC-Emotion-Lexicon-Wordlevel-v0.92.txt",
"NRC-v0.92.txt"),
col_names = c("word", "sentiment", "flag"), col_types = "ccd") %>%
filter(flag == 1) %>% select(word, sentiment)
bing <- get_sentiments("bing")
c(afinn_words = nrow(afinn), nrc_pairs = nrow(nrc), bing_words = nrow(bing))
## afinn_words nrc_pairs bing_words
## 2477 13901 6786
Our group collected three Bluesky scrapes, one for each week:
| Week | File | Search term | Encoding | Timestamp column | Posts used |
|---|---|---|---|---|---|
| Week 1 | movie-scrape-1.csv | “movies” | Windows-1252 (saved from Excel) | created_at |
Nov 3 evening (Election Day / Godzilla Day) |
| Week 2 | movie-scrape-2.csv | “movies” | UTF-8 | indexed_at |
Nov 19 afternoon |
| Week 3 | movie-scrape-3.csv | “movie theatre” | UTF-8 | indexed_at |
Nov 23 to Dec 1 (Thanksgiving week) |
Scrape 3 returned posts from Nov 16 to Dec 1. Its Nov 16 to 22 posts overlap Week 2 (17 posts appear in both files), so we keep only scrape 3’s posts from Nov 23 onward. That way each week covers a separate period. Scrape 3 also used a narrower search term (“movie theatre”), which we keep in mind when comparing Week 3 with the first two weeks.
Each file is read with its own encoding, whichever timestamp it has is used, and engagement is calculated the same way for every post: likes + reposts + replies.
week_files <- tribble(
~week, ~file, ~encoding, ~keep_from,
"Week 1 (Nov 3)", "movie-scrape-1.csv", "windows-1252", NA,
"Week 2 (Nov 19)", "movie-scrape-2.csv", "UTF-8", NA,
"Week 3 (Nov 23-Dec 1)", "movie-scrape-3.csv", "UTF-8", "2026-11-23"
)
read_week <- function(week, file, encoding, keep_from) {
d <- read_csv(file, locale = locale(encoding = encoding),
col_types = cols(.default = col_character()))
ts <- if ("created_at" %in% names(d)) d$created_at else d$indexed_at
out <- tibble(
week = week,
text = replace_na(d$text, ""),
author_handle = d$author_handle,
posted_at = suppressWarnings(parse_date_time(ts, orders = c("Ymd HMS", "Ymd HM", "mdY HM", "mdY HMS"))),
like_count = as.numeric(d$like_count),
repost_count = as.numeric(d$repost_count),
reply_count = as.numeric(d$reply_count)
)
if (!is.na(keep_from)) out <- filter(out, as_date(posted_at) >= ymd(keep_from))
out
}
raw <- pmap_dfr(week_files, read_week) %>%
mutate(week = factor(week, levels = week_files$week),
across(c(like_count, repost_count, reply_count), ~ replace_na(.x, 0)),
engagement = like_count + repost_count + reply_count,
post_id = row_number())
raw %>% group_by(week) %>%
summarise(posts = n(), first = min(posted_at, na.rm = TRUE), last = max(posted_at, na.rm = TRUE),
median_engagement = median(engagement))
The same steps run on every week, and the count after each step is logged.
cleaning_log <- tibble()
log_step <- function(step, data) {
cleaning_log <<- bind_rows(cleaning_log,
data %>% count(week, name = "posts") %>% mutate(step = step))
}
log_step("0. Raw scrape", raw)
posts <- raw %>%
mutate(
nsfw = str_detect(str_to_lower(text), "nsfw"),
clean_text = text %>%
str_replace_all("[\u2018\u2019]", "'") %>%
str_replace_all("[\u201C\u201D]", '"') %>%
str_replace_all("[\u2013\u2014]", " - ") %>%
str_replace_all("\u2026", " ") %>%
str_replace_all(""", '"') %>%
str_replace_all("@[\\w.-]+", " ") %>% # @mentions
str_replace_all("https?://\\S+|www\\.\\S+", " ") %>% # full URLs
str_replace_all("\\b[a-z0-9.-]+\\.(com|org|net|co|to|in|uk|be|social|app|io|online|jp|us|gy|amazon)(/\\S*)?", " ") %>% # bare links
str_replace_all("#\\S+", " ") %>% # hashtags
str_replace_all("\\?{2,}|(^|\\s)\\?+", " ") %>% # emoji placeholders from the Excel export
str_squish(),
n_words = str_count(clean_text, "[A-Za-z']+")
)
posts <- posts %>% filter(n_words >= 3)
log_step("1. Remove empty / link-only / <3-word posts", posts)
cld2 was used on the Nov 3 data, but it made mistakes
there (it called an English Godzilla list Polish). Here we use a
simpler, transparent rule that works without extra packages: a post is
kept if at least half of its words are common English stop words or
appear in the Bing/AFINN lexicons, or if at least 85%
of its letters are basic Latin (A to Z). The removed posts are printed
for review.
english_vocab <- unique(c(stop_words$word, bing$word, afinn$word))
lang_check <- posts %>%
select(post_id, clean_text) %>%
unnest_tokens(word, clean_text) %>%
group_by(post_id) %>%
summarise(share_english_words = mean(word %in% english_vocab), .groups = "drop")
posts <- posts %>%
left_join(lang_check, by = "post_id") %>%
mutate(share_ascii = str_count(clean_text, "[A-Za-z]") / pmax(str_count(clean_text, "\\p{L}"), 1),
english = share_english_words >= 0.5 | (share_ascii >= 0.85 & share_english_words >= 0.3))
posts %>% filter(!english) %>% select(week, author_handle, clean_text) %>%
mutate(clean_text = str_trunc(clean_text, 90))
posts <- posts %>% filter(english)
log_step("2. Remove non-English posts", posts)
Two rules. First, the accounts Gian identified by reading the Nov 3 posts. Second, any account that posts 4 or more times in one week is printed for review. Those turned out to be automated news reposters, music promotion, or deal posts rather than opinions about movies, so they are removed too.
spam_accounts <- c("justpastemovies.bsky.social", "jazzcomposer.bsky.social", "bot-tan.com",
"nowbreezing.ntw.app", "emme-gray.bsky.social", "nearskill.bsky.social",
"videogamedepot.bsky.social", "hollywoodmetrics.bsky.social",
"plot-hole-game.bsky.social", "classicfilms.app", "florestario.bsky.social")
heavy_posters <- posts %>% count(week, author_handle) %>% filter(n >= 4)
heavy_posters %>%
left_join(posts %>% group_by(author_handle) %>% slice_head(n = 1) %>%
select(author_handle, example = clean_text), by = "author_handle") %>%
mutate(example = str_trunc(example, 90))
posts <- posts %>%
filter(!author_handle %in% c(spam_accounts, heavy_posters$author_handle))
log_step("3. Remove spam / bot / promo accounts", posts)
posts <- posts %>% distinct(clean_text, .keep_all = TRUE)
log_step("4. Remove duplicate posts", posts)
The Nov 3 scrape ran on Election Day, so posts that mention movies only in passing while talking about politics are removed with the same keyword filter used before.
political_terms <- c("election", "elect", "trump", "maga", "nazi", "nazis", "republican",
"democrat", "democracy", "senate", "midterm", "vote", "voting",
"voters", "polls", "gop", "gov", "governor", "politic", "political",
"kornacki")
political_regex <- paste0("\\b(", paste(political_terms, collapse = "|"), ")\\b")
political_keep <- c("hmuncut.bsky.social", "semetrarhodes.bsky.social") # really about movies (Nov 3 review)
posts <- posts %>%
filter(!str_detect(str_to_lower(clean_text), political_regex) | author_handle %in% political_keep,
!nsfw)
log_step("5. Remove political / off-topic / NSFW posts", posts)
cleaning_log %>%
pivot_wider(names_from = week, values_from = posts) %>%
relocate(step)
Final clean dataset: 894 posts from 1081 raw posts.
write_csv(posts %>% select(week, author_handle, posted_at, clean_text, like_count,
repost_count, reply_count, engagement),
"bluesky_movies_clean.csv")
The search keywords (“movies”, “movie”, “film”, “theatre”, “theater”) are removed because they appear in nearly every post by design.
custom_stop <- tibble(word = c("movies", "movie", "film", "films", "theatre", "theater", "it's", "i'm", "don't",
"amp", "gt", "lt", "i've", "that's", "can't"))
tokens <- posts %>%
select(post_id, week, clean_text, engagement) %>%
unnest_tokens(word, clean_text)
content_words <- tokens %>%
anti_join(stop_words, by = "word") %>%
anti_join(custom_stop, by = "word") %>%
filter(!str_detect(word, "^\\d+$"), nchar(word) > 1)
content_words %>% count(word, sort = TRUE) %>%
slice_max(n, n = 15, with_ties = FALSE) %>%
ggplot(aes(n, reorder(word, n))) +
geom_col(fill = "#8C1C2B") +
labs(title = "Top 15 words, all weeks combined", x = "Count", y = NULL) +
theme_minimal()
content_words %>%
count(week, word, sort = TRUE) %>%
group_by(week) %>% slice_max(n, n = 10, with_ties = FALSE) %>% ungroup() %>%
mutate(word = reorder_within(word, n, week)) %>%
ggplot(aes(n, word)) +
geom_col(fill = "#8C1C2B") +
scale_y_reordered() +
facet_wrap(~ week, scales = "free") +
labs(title = "Top 10 words by week", x = "Count", y = NULL) +
theme_minimal()
TF-IDF gives a high score to words that are frequent in one week but rare in the others. It shows what each week’s conversation was about. A word used in all three weeks gets a TF-IDF of 0, so this chart shows words concentrated in one or two weeks.
week_tfidf <- content_words %>%
count(week, word) %>%
bind_tf_idf(word, week, n) %>%
filter(n >= 3, idf > 0) # words used 3+ times that are not in every week
week_tfidf %>%
group_by(week) %>% slice_max(tf_idf, n = 10, with_ties = FALSE) %>% ungroup() %>%
mutate(word = reorder_within(word, tf_idf, week)) %>%
ggplot(aes(tf_idf, word)) +
geom_col(fill = "#D99A1E") +
scale_y_reordered() +
facet_wrap(~ week, scales = "free") +
labs(title = "Most distinctive words by week (TF-IDF)", x = "TF-IDF", y = NULL) +
theme_minimal()
posts %>%
unnest_tokens(bigram, clean_text, token = "ngrams", n = 2) %>%
filter(!is.na(bigram)) %>%
separate(bigram, into = c("w1", "w2"), sep = " ") %>%
filter(!w1 %in% stop_words$word, !w2 %in% stop_words$word,
!w1 %in% custom_stop$word, !w2 %in% custom_stop$word) %>%
unite(bigram, w1, w2, sep = " ") %>%
count(week, bigram, sort = TRUE) %>%
group_by(week) %>% slice_head(n = 8)
| Lexicon | What it gives | Post score used here |
|---|---|---|
| Bing | Each word is positive or negative | # positive − # negative words |
| AFINN | Each word is an integer from −5 to +5 | Sum of word values |
| NRC | 8 emotions + positive/negative | # positive − # negative |
As in the Nov 3 analysis, the word “like” is excluded from scoring. In these posts it is almost always filler or a comparison (“flew by like it was nothing”), and it was Bing’s most common “positive” word. Stop words are otherwise kept so that words like “love” or “bad” are never dropped. A post with no lexicon words scores 0 (neutral).
score_tokens <- tokens %>% filter(word != "like")
bing_scores <- score_tokens %>%
inner_join(bing, by = "word") %>%
count(post_id, sentiment) %>%
pivot_wider(names_from = sentiment, values_from = n, values_fill = 0) %>%
transmute(post_id, bing_score = positive - negative)
afinn_scores <- score_tokens %>%
inner_join(afinn, by = "word") %>%
group_by(post_id) %>% summarise(afinn_score = sum(value), .groups = "drop")
nrc_scores <- score_tokens %>%
inner_join(filter(nrc, sentiment %in% c("positive", "negative")), by = "word",
relationship = "many-to-many") %>%
count(post_id, sentiment) %>%
pivot_wider(names_from = sentiment, values_from = n, values_fill = 0) %>%
transmute(post_id, nrc_score = positive - negative)
label <- function(x) factor(case_when(x > 0 ~ "Positive", x < 0 ~ "Negative", TRUE ~ "Neutral"),
levels = c("Positive", "Neutral", "Negative"))
scored <- posts %>%
select(post_id, week, author_handle, clean_text, like_count, repost_count, reply_count, engagement) %>%
left_join(bing_scores, by = "post_id") %>%
left_join(afinn_scores, by = "post_id") %>%
left_join(nrc_scores, by = "post_id") %>%
mutate(across(c(bing_score, afinn_score, nrc_score), ~ replace_na(.x, 0)),
bing_label = label(bing_score), afinn_label = label(afinn_score), nrc_label = label(nrc_score))
sent_by_week <- scored %>%
pivot_longer(c(bing_label, afinn_label, nrc_label), names_to = "lexicon", values_to = "label") %>%
mutate(lexicon = recode(lexicon, bing_label = "Bing", afinn_label = "AFINN", nrc_label = "NRC")) %>%
count(week, lexicon, label) %>%
group_by(week, lexicon) %>% mutate(share = n / sum(n)) %>% ungroup()
sent_by_week %>%
select(-n) %>%
mutate(share = percent(share, accuracy = 1)) %>%
pivot_wider(names_from = label, values_from = share)
ggplot(sent_by_week, aes(x = lexicon, y = share, fill = label)) +
geom_col() +
facet_wrap(~ week) +
scale_y_continuous(labels = percent) +
scale_fill_manual(values = c(Positive = "#2C7FB8", Neutral = "#BDBDBD", Negative = "#D7301F")) +
labs(title = "Share of posts by sentiment label, by week and lexicon", x = NULL, y = "Share of posts", fill = NULL) +
theme_minimal()
scored %>% group_by(week) %>%
summarise(posts = n(), mean_afinn = round(mean(afinn_score), 2),
mean_bing = round(mean(bing_score), 2), mean_nrc = round(mean(nrc_score), 2))
agreement <- scored %>%
group_by(week) %>%
summarise(bing_vs_afinn = mean(bing_label == afinn_label),
bing_vs_nrc = mean(bing_label == nrc_label),
afinn_vs_nrc = mean(afinn_label == nrc_label),
all_three = mean(bing_label == afinn_label & afinn_label == nrc_label),
.groups = "drop")
agreement %>% mutate(across(-week, ~ percent(.x, accuracy = 1)))
all_three_overall <- mean(scored$bing_label == scored$afinn_label & scored$afinn_label == scored$nrc_label)
score_tokens %>%
inner_join(bing, by = "word") %>%
count(sentiment, word, sort = TRUE) %>%
group_by(sentiment) %>% slice_head(n = 10) %>%
ggplot(aes(n, reorder(word, n), fill = sentiment)) +
geom_col(show.legend = FALSE) +
facet_wrap(~ sentiment, scales = "free_y") +
scale_fill_manual(values = c(negative = "#D7301F", positive = "#2C7FB8")) +
labs(title = "Top words behind Bing sentiment (all weeks)", x = "Count", y = NULL) +
theme_minimal()
nrc_emotions <- score_tokens %>%
inner_join(filter(nrc, !sentiment %in% c("positive", "negative")), by = "word",
relationship = "many-to-many") %>%
count(week, sentiment) %>%
group_by(week) %>% mutate(share = n / sum(n)) %>% ungroup()
ggplot(nrc_emotions, aes(share, reorder(sentiment, share), fill = week)) +
geom_col(position = "dodge") +
scale_x_continuous(labels = percent) +
scale_fill_manual(values = c("#8C1C2B", "#D99A1E", "#2E4057", "#7A7A7A")) +
labs(title = "NRC emotion words as a share of each week's emotion words", x = "Share", y = NULL, fill = NULL) +
theme_minimal()
score_tokens %>%
inner_join(filter(nrc, sentiment %in% c("fear", "anticipation", "joy")), by = "word",
relationship = "many-to-many") %>%
count(sentiment, word, sort = TRUE) %>%
group_by(sentiment) %>% slice_head(n = 6)
Engagement is heavily skewed (most posts get 0 or 1), so we use the Spearman rank correlation.
eng_cor <- scored %>%
group_by(week) %>%
summarise(posts = n(),
zero_engagement = percent(mean(engagement == 0), accuracy = 1),
median_engagement = median(engagement),
spearman_rho = cor(afinn_score, engagement, method = "spearman"),
p_value = cor.test(afinn_score, engagement, method = "spearman", exact = FALSE)$p.value,
.groups = "drop")
eng_cor
overall_cor <- cor.test(scored$afinn_score, scored$engagement, method = "spearman", exact = FALSE)
overall_cor
##
## Spearman's rank correlation rho
##
## data: scored$afinn_score and scored$engagement
## S = 121663719, p-value = 0.518
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## -0.02164574
scored %>% group_by(bing_label) %>%
summarise(posts = n(), mean_engagement = round(mean(engagement), 1),
median_engagement = median(engagement), .groups = "drop")
plot_data <- scored %>%
mutate(hover = paste0("<b>@", author_handle, "</b> (", week, ")<br>",
str_wrap(str_trunc(clean_text, 220), 60) %>% str_replace_all("\n", "<br>"),
"<br><br>AFINN: ", afinn_score, " | Bing: ", bing_score,
"<br>Likes: ", like_count, " | Reposts: ", repost_count, " | Replies: ", reply_count))
plot_ly(plot_data, x = ~afinn_score, y = ~engagement, color = ~week,
colors = c("#8C1C2B", "#D99A1E", "#2E4057", "#7A7A7A"),
type = "scatter", mode = "markers",
marker = list(size = 8, opacity = 0.7, line = list(width = 0.5, color = "white")),
text = ~hover, hoverinfo = "text") %>%
layout(title = list(text = "Sentiment vs. engagement: Bluesky 'movies' posts", x = 0.02, xanchor = "left"),
xaxis = list(title = "AFINN sentiment score"),
yaxis = list(title = "Engagement (likes + reposts + replies)", type = "log"),
margin = list(t = 60))
Note: the y-axis uses a log scale so the few viral posts don’t flatten the rest. Posts with 0 engagement can’t be shown on a log scale and are hidden in this chart only; they are included in every calculation.
Marketing takeaway: For a movie theater marketer, what people talk about (tentpole releases, anniversaries like Godzilla Day, holiday screenings, special events at local theaters) shapes the conversation far more than how positive posts sound. When people post about theaters, they talk about experiences: marathons, 35mm and anniversary screenings, the crowd’s reaction. Timing campaigns to the event and holiday calendar, and promoting the experience, is more useful than chasing positive sentiment. This lines up with our survey: attitude toward the at-home experience, not price, explained theater attendance.
Limitations: Weeks 1 and 2 are short snapshots (about 1.5 hours on Nov 3 and about 3 hours on Nov 19), while Week 3 covers nine days. Week 3 used a different search term (“movie theatre” rather than “movies”), so some differences between weeks come from the search, not from a change in opinion. We dropped scrape 3’s Nov 16 to 22 posts so the weeks do not overlap. Emojis were lost in the Excel export of the Nov 3 file. Engagement was captured at scrape time, so recent posts had less time to collect likes. The Week 2 and 3 files record when Bluesky indexed each post rather than when it was created.
R code was drafted with Claude (Anthropic) from our prompts, then run, checked, and edited by us. AI was used to organize the code, extend the Nov 3 analysis to multiple weeks, and troubleshoot errors. The cleaning decisions, interpretation of results, and final review were done by our group.