Skip to content

Commit

Permalink
Add fixes for quanteda v4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chainsawriot committed Apr 12, 2024
1 parent 81db909 commit 011eb60
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions vignettes/btm.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```
6 changes: 4 additions & 2 deletions vignettes/overview.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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) %>%
Expand Down Expand Up @@ -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) %>%
Expand Down

0 comments on commit 011eb60

Please sign in to comment.