Systematic literature review

NLP techniques used in marketing

Authors
Affiliation

Olivier Caron

Paris Dauphine - PSL

Christophe Benavent

Paris Dauphine - PSL

Published

October 4, 2023

1 Libraries R and loading data

Code
library(tidyverse)
library(reactable)
library(plotly)
library(wesanderson)
Code
#load data
data_embeddings <- read.csv("data_for_embeddings.csv")
annotations_stanza <- read.csv("annotated_stanza.csv")
annotations_udpipe <- read.csv("annotated_udpipe.csv")
annotations_trankit <- read.csv("annotated_trankit.csv")

2 Loading of all annotations (Stanza, UDPipe, Trankit)

Code
#annotation filter on PROPN
annotations_stanza_propn <- annotations_stanza %>% filter(upos == "PROPN")
annotations_udpipe_propn <- annotations_udpipe %>% filter(upos == "PROPN")
annotations_trankit_propn <- annotations_trankit %>% filter(upos == "PROPN")

#list of most frequent words in annotatinos
toppropn_stanza <- annotations_stanza_propn %>% count(lemma, sort = TRUE) %>% drop_na() %>% filter(n > 1)
toppropn_udpipe <- annotations_udpipe_propn %>% count(lemma, sort = TRUE) %>% drop_na() %>% filter(n > 1)
toppropn_trankit <- annotations_trankit_propn %>% count(lemma, sort = TRUE) %>% drop_na() %>% filter(n > 1)

2.1 Table of most frequent PROPN words in the Stanza annotations

Code
#reactable of most frequent words in annotations_propn
toppropn_stanza %>% 
  reactable(
    searchable = TRUE,
    defaultColDef = colDef(
      minWidth = 100,
      sortable = TRUE
    )
  )

2.2 Table of most frequent PROPN words in the UDPipe annotations

Code
#reactable of most frequent words in annotations_propn
toppropn_udpipe %>% 
  reactable(
    searchable = TRUE,
    defaultColDef = colDef(
      minWidth = 100,
      sortable = TRUE
    )
  )

2.3 Table of most frequent PROPN words in the Trankit annotations

Code
#reactable of most frequent words in annotations_propn
toppropn_trankit %>% 
  reactable(
    searchable = TRUE,
    defaultColDef = colDef(
      minWidth = 100,
      sortable = TRUE
    )
  )

3 NLP techniques in Marketing

3.1 Generic techniques

We want to provide a list of recurrent techniques in marketing. The tables above clearly show that some of them are often used. Let’s focus first on them in no particular order.

  • LIWC

  • Leximancer

  • BERT

  • ChatGPT

  • PassivePy

Code
#i want to get just one number if multiple words of the vector are found in the string


#detect and count the words above in the "combined_text" column of data_embeddings
data_embeddings$combined_text <- tolower(data_embeddings$combined_text)
data_embeddings$liwc <- str_count(data_embeddings$combined_text, "liwc")
data_embeddings$leximancer <- str_count(data_embeddings$combined_text, "leximancer")
data_embeddings$bert <- str_count(data_embeddings$combined_text, "bert")
data_embeddings$chatgpt <- str_count(data_embeddings$combined_text, "chatgpt")
data_embeddings$passivepy <- str_count(data_embeddings$combined_text, "passivepy")

# Group by year and calculate the cumulative sum for each technique
sum_data <- data_embeddings %>%
  group_by(year) %>%
  summarize(
    sum_liwc = sum(liwc),
    sum_leximancer = sum(leximancer),
    sum_bert = sum(bert),
    sum_chatgpt = sum(chatgpt),
    sum_passivepy = sum(passivepy)
  ) %>%
  ungroup()

cumulative_data <- sum_data %>%
  mutate(
    cum_liwc = cumsum(sum_liwc),
    cum_leximancer = cumsum(sum_leximancer),
    cum_bert = cumsum(sum_bert),
    cum_chatgpt = cumsum(sum_chatgpt),
    cum_passivepy = cumsum(sum_passivepy)
  ) %>%
  filter(year > 2012)

patterns <- c("linguistic inquiry and word count", "linguistic inquiry", "linguistic inquiry word count", "liwc")

# Create a new column "liwc_alt" with initial empty strings
data_embeddings$liwc_alt <- ""

# Find the column index for "liwc_alt"
ncol <- which(colnames(data_embeddings) == "liwc_alt")

# Loop through each row and pattern to count occurrences and populate "liwc_alt"
for (i in 1:nrow(data_embeddings)) {
  counts <- sapply(patterns, function(pattern) {
    str_count(data_embeddings$combined_text[i], pattern)
  })
  data_embeddings$liwc_alt[i] <- sum(counts)
}

liwc_df <- data_embeddings %>% select(combined_text, liwc, liwc_alt)
reactable(liwc_df, searchable = TRUE, 
          defaultPageSize = 3,  # Set the maximum number of rows to display
          columns = list(
            combined_text = colDef(width = 850),
            liwc = colDef(width = 50),
            liwc_alt = colDef(width = 50)
          ))

It seems that when researchers talk about LIWC, they always include “liwc” but not always “linguistic inquiry and word count” or other variations. We can therefore concentrate on the unique detection of “liwc”, “bert” and other acronyms in the text.

We use the wesanderson package to get a nice palette of colors. We pick the Royal2 palette.

Code
Royal2 <- wesanderson::wes_palette("Royal2")

fig <- ggplot(cumulative_data, aes(x = year)) +
  geom_line(aes(y = cum_liwc, linetype = "LIWC", color = "LIWC")) +
  geom_line(aes(y = cum_leximancer, linetype = "Leximancer", color = "Leximancer")) +
  geom_line(aes(y = cum_bert, linetype = "BERT", color = "BERT")) +
  geom_line(aes(y = cum_chatgpt, linetype = "ChatGPT", color = "ChatGPT")) +
  geom_line(aes(y = cum_passivepy, linetype = "PassivePy", color = "PassivePy")) +
  scale_color_manual(
    name = "Techniques",
    values = Royal2
  ) +
  scale_linetype_manual(
    name = "Techniques",
    values = c(
      "LIWC" = "solid",
      "Leximancer" = "dashed",
      "BERT" = "dotted",
      "ChatGPT" = "dotdash",
      "PassivePy" = "longdash"
    ),
    guide = guide_legend(override.aes = list(linetype = "solid"))  # Set the legend linetype to "solid"
  ) +
  labs(
    title = "Evolution of NLP techniques in marketing",
    subtitle = "Cumulative sum of the number of articles mentioning each technique",
    x = "",
    y = "Cumulative number of occurrences"
  ) +
  scale_x_continuous(breaks = seq(2010, 2023, by = 1), labels = seq(2010, 2023, by = 1)) +  # Set breaks and labels
  theme_minimal() +
  theme(legend.position = "bottom")  # Move the legend to the bottom for better visibility

ggplotly(fig)

It seems like Leximancer is coming to an end, while BERT and ChatGPT are on the rise. PassivePy is also gaining traction but we can’t really conclude anything about it yet since the article has been published in 2022 @(sepehri2022passivepy). One interesthing to notice is that BERT