This function wraps prsp_score and loops over your text input. Provide a character string with your text and which scores you want to obtain. Make sure to keep track of your ratelimit with on the cloud console quota usage page.

prsp_stream(
  .data,
  text = NULL,
  text_id = NULL,
  ...,
  safe_output = F,
  verbose = F,
  save = F,
  dt_name = "persp"
)

Arguments

.data

a dataset with a text and text_id column.

text

a character vector with text you want to score.

text_id

a unique ID for the text that you supply (required)

...

arguments passed to prsp_score. Don't forget to add the score_model argument (see peRspective::prsp_models for list of valid models).

safe_output

wraps the function into a purrr::safely environment (defaults to FALSE). Loop will run without pause and catch + output errors in a tidy tibble along with the results.

verbose

narrates the streaming procedure (defaults to FALSE).

save

NOT USABLE YET saves data into SQLite database (defaults to FALSE).

dt_name

NOT USABLE YET what is the name of the dataset? (defaults to persp).

Value

a tibble

Details

For more details see ?peRspective or Perspective API documentation

Examples

if (FALSE) { ## Create a mock tibble text_sample <- tibble( ctext = c("You wrote this? Wow. This is dumb and childish, please go f**** yourself.", "I don't know what to say about this but it's not good. The commenter is just an idiot", "This goes even further!", "What the hell is going on?", "Please. I don't get it. Explain it again", "Annoying and irrelevant! I'd rather watch the paint drying on the wall!"), textid = c("#efdcxct", "#ehfcsct", "#ekacxwt", "#ewatxad", "#ekacswt", "#ewftxwd") ) ## GET TOXICITY and SEVERE_TOXICITY Scores for a dataset with a text column text_sample %>% prsp_stream(text = ctext, text_id = textid, score_model = c("TOXICITY", "SEVERE_TOXICITY")) ## Safe Output argument means will not stop on error prsp_stream(text = ctext, text_id = textid, score_model = c("TOXICITY", "SEVERE_TOXICITY"), safe_output = T) ## verbose = T means you get pretty narration of your scoring procedure prsp_stream(text = ctext, text_id = textid, score_model = c("TOXICITY", "SEVERE_TOXICITY"), safe_output = T, verbose = T) }