tardis_multidict | R Documentation |
This convenience function takes a text and a set of dictionaries, and calls
tardis::tardis()
once for each dictionary. Other parameters are also passed
along to tardis()
.
tardis_multidict(input_text, text_column = NA, dictionaries, ...)
input_text |
A text to be analyzed, either a |
text_column |
If |
dictionaries |
A single |
... |
Other parameters passed on to |
Dictionaries must be in a single tbl_df
with at least two columns:
token
, containing the tokens belonging to each dictionary; and dicionary
,
which contains a unique identifier mapping each token to a dictionary.
Weights, if present, must be in a column named score
.
Tokens can be mapped to multiple dictionaries, but each row maps one token to one dictionary.
A tbl_df
with new columns for each dictionary.
## Not run: library(magrittr) # Get NRC emotions dataset from textdata package nrc_emotion <- textdata::lexicon_nrc() %>% dplyr::rename(token = word, dictionary = sentiment) %>% dplyr::mutate(score = 1) # set up some input text text <- dplyr::tibble(body = c("I am so angry!", "I am angry.", "I'm not angry.", "Your mother and I aren't angry, we're just disappointed.")) emotions <- tardis_multidict(input_text = text, text_column = "body", dictionaries = nrc_emotion) %>% dplyr::select(body, score_anger, score_sadness) emotions ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.