Skip to content

Instantly share code, notes, and snippets.

@Rekyt
Created November 8, 2017 10:06
Show Gist options
  • Select an option

  • Save Rekyt/7d24c31239309967bba06730c9a809b3 to your computer and use it in GitHub Desktop.

Select an option

Save Rekyt/7d24c31239309967bba06730c9a809b3 to your computer and use it in GitHub Desktop.
# Text analysis of Proust
library(proustr)
library(tidytext)
library(dplyr)
library(stringr)
proust_words = proust_books() %>%
group_by(book) %>%
mutate(linenumber = row_number(),
chapter = cumsum(str_detect(text, regex("^chapitre [\\divxlc]",
ignore_case = TRUE)))) %>%
ungroup() %>%
unnest_tokens(word, text)
mot_avec_cedille = proust_words %>%
filter(grepl("ç", word, fixed = TRUE) |
grepl("Ç", word, fixed = TRUE)) %>%
select(word) %>%
distinct()
proust_words %>%
inner_join(mot_avec_cedille, by = "word") %>%
count(word, sort = TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment