Unveiling the Language of Love with Data 💕

Our dataset comprises a collection of 88 love letters, each a testament to the myriad ways individuals express affection, longing, and devotion through written words. By leveraging data science techniques, we aim to uncover hidden insights, patterns, and trends that illuminate the language of love. From sentiment analysis to word frequency exploration, this project delves into the nuanced and intricate landscape of romantic correspondence.

Whether you are a data enthusiast, a linguist, or simply someone fascinated by the complexities of human connection, this project invites you to explore the intersection of emotion and data through the lens of love letters! 💌


# Install and load necessary packages
install.packages(c("readr", "tidytext", "dplyr", "ggplot2"))
## 
## The downloaded binary packages are in
##  /var/folders/tt/_w3xknfj38j35q38wz550c480000gn/T//Rtmpyx55kW/downloaded_packages
library(readr)
library(tidytext)
library(dplyr)
library(ggplot2)

# Create an empty list to store the love letters
love_letters_list <- list()

# Read love letters into the list
for (i in 0:87) {
  file_path <- paste0("/Users/talkadosh/Desktop/LoveLetters/", i, ".txt")
  love_letter <- read_file(file_path)
  love_letters_list[[i + 1]] <- tibble(value = love_letter)
}

# Combine the love letters into a single tibble
data <- bind_rows(love_letters_list, .id = "letter_id")

# Load stop words
data(stop_words)

# Tokenize and tidy the data
tidy_data <- data %>%
  unnest_tokens(input = value, output = word, token = "words") %>%
  anti_join(stop_words) %>%
  count(word, sort = TRUE)
## Joining with `by = join_by(word)`
# Filter out specific words
tidy_data <- tidy_data %>%
  filter(word != "love") %>%
  filter(word != "heart")
  
# Display top N words
N <- 30
topN <- tidy_data %>%
  slice_max(n, n = N, with_ties = FALSE)

# Create a bar plot
ggplot(data = topN, aes(x = reorder(word, n), y = n, fill = n)) +
  geom_col(color = "white") +
  scale_fill_gradient(low = "lightpink", high = "darkred") +
  coord_flip() +
  labs(
    title = "Love Letters Analysis",
    subtitle = paste("Based on word prevalence, the most used 30 words are:"),
    x = "Words",
    y = "Frequency"
  ) +
  theme_minimal()


Crafting the Ultimate Love Letter with ChatGPT 💘

But our journey doesn’t end there. Armed with these insights, we’ve enlisted the assistance of ChatGPT to compose the ultimate love letter. Because, who says AI can’t channel a little bit of romance? ;)

Feel free to use the crafted template to express your deepest emotions to your beloved one:


Dearest Love,

On this V-Day, I write a letter to thee, my heart and soul. In the journey of life, every day and night, your kiss brings happiness. Your words are my truest hope, a beautiful melody to my mind. I don’t live for a thousand days, but for each moment with thee. In the embrace of your love, I find mine. In the embrace of your love, I feel the timeless connection written in the letters of our hearts, a bond cherished and nurtured like the love of a mother. Don’t forget, my dear, in your arms, I’ve found the true meaning of living. Thank you for being my darling and my everything.

With all my love, till god or death will do us part,

[Your Name]


As we celebrate Valentine’s Day, may this endeavor add a touch of data-driven enchantment to your celebration of love.

Happy Valentine’s Day! 💖