From 011eb601d0b7a324f47e2a51c6d063be1ab81cbb Mon Sep 17 00:00:00 2001 From: chainsawriot Date: Fri, 12 Apr 2024 16:46:04 +0200 Subject: [PATCH] Add fixes for quanteda v4.0.0 --- vignettes/btm.Rmd | 4 ++-- vignettes/overview.Rmd | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/vignettes/btm.Rmd b/vignettes/btm.Rmd index 18686fa..0525027 100644 --- a/vignettes/btm.Rmd +++ b/vignettes/btm.Rmd @@ -101,12 +101,12 @@ oolong `btm_dataframe` must not be NULL. -```{r, error = TRUE} +```{r btm_error1, error = TRUE} oolong <- create_oolong(trump_btm, trump_corpus) ``` `input_corpus` must be a quanteda corpus. -```{r, error = TRUE} +```{r btm_error2, error = TRUE} oolong <- create_oolong(trump_btm, trump2k, btm_dataframe = trump_dat) ``` diff --git a/vignettes/overview.Rmd b/vignettes/overview.Rmd index 10a2fe6..8db17f2 100644 --- a/vignettes/overview.Rmd +++ b/vignettes/overview.Rmd @@ -327,7 +327,8 @@ In this example, we calculate the AFINN score for each tweet using quanteda. The ```{r} gold_standard <- oolong_test$turn_gold() -dfm(gold_standard, remove_punct = TRUE) %>% dfm_lookup(afinn) %>% quanteda::convert(to = "data.frame") %>% +gold_standard %>% tokens(remove_punct = TRUE) %>% dfm() %>% dfm_lookup(afinn) %>% + quanteda::convert(to = "data.frame") %>% mutate(matching_word_valence = (neg5 * -5) + (neg4 * -4) + (neg3 * -3) + (neg2 * -2) + (neg1 * -1) + (zero * 0) + (pos1 * 1) + (pos2 * 2) + (pos3 * 3) + (pos4 * 4) + (pos5 * 5), base = ntoken(gold_standard, remove_punct = TRUE), afinn_score = matching_word_valence / base) %>% @@ -421,7 +422,8 @@ Calculate the target value (in this case, the AFINN score) by turning one object ```{r} gold_standard <- trump$turn_gold() -dfm(gold_standard, remove_punct = TRUE) %>% dfm_lookup(afinn) %>% quanteda::convert(to = "data.frame") %>% +gold_standard %>% tokens(remove_punct = TRUE) %>% dfm() %>% + dfm_lookup(afinn) %>% quanteda::convert(to = "data.frame") %>% mutate(matching_word_valence = (neg5 * -5) + (neg4 * -4) + (neg3 * -3) + (neg2 * -2) + (neg1 * -1) + (zero * 0) + (pos1 * 1) + (pos2 * 2) + (pos3 * 3) + (pos4 * 4) + (pos5 * 5), base = ntoken(gold_standard, remove_punct = TRUE), afinn_score = matching_word_valence / base) %>%