Generates valence scores for each row in a given column of text.

score_valence(
 df,
 text_var = Message,
 valence_limits = c(-Inf, Inf),
 remove_terms = NULL,
 highlight = FALSE
)

Arguments

df

A dataframe.

text_var

The variable containing the text to be scored.

valence_limits

Numerical lower and upper bounds for valence scores.

remove_terms

Vector of terms to remove from the Jockers-Rinker valence library.

highlight

Logical indicating whether highlighted text should be returned.

Value

Adds 3 variables to the supplied data: ave_sentiment, word_count, sd.

Examples

score_valence(
 df = sprinklr_export,
 text_var = Message,
 valence_limits = c(-2, 2),
 remove_terms = c("foo", "bar"),
 highlight = FALSE
)
#> # A tibble: 6,018 × 58
#>    message_id UniversalMessageId     SocialNetwork SenderUserId SenderScreenName
#>         <int> <chr>                  <chr>         <chr>        <chr>           
#>  1          1 INSTAGRAM_36_19027908… INSTAGRAM     ude_aku      ude_aku         
#>  2          2 INSTAGRAM_36_19027826… INSTAGRAM     ude_aku      ude_aku         
#>  3          3 TWITTER_4_10578602917… TWITTER       100818788    pragmaticmom    
#>  4          4 TWITTER_2_10578458995… TWITTER       2777150217   LAVCPrez        
#>  5          5 TWITTER_4_10578280142… TWITTER       2366576322   Valley_Vikings  
#>  6          6 TWITTER_2_10578220833… TWITTER       1723468759   PearceAVID      
#>  7          7 TWITTER_4_10578180262… TWITTER       328184177    JohnHSandbach   
#>  8          8 TWITTER_2_10578147941… TWITTER       1515570781   Miriam_A3       
#>  9          9 TWITTER_2_10578031519… TWITTER       1449659010   CypressCreekHS  
#> 10         10 TWITTER_2_10578030531… TWITTER       1449659010   CypressCreekHS  
#> # … with 6,008 more rows, and 53 more variables: SenderListedName <chr>,
#> #   SenderProfileImgUrl <chr>, SenderProfileLink <lgl>,
#> #   `Sender Followers Count` <dbl>, SenderInfluencerScore <lgl>,
#> #   SenderAge <lgl>, SenderGender <chr>, Title <chr>, Message <chr>,
#> #   MessageType <chr>, CreatedTime <dttm>, Language <chr>, LanguageCode <chr>,
#> #   CountryCode <chr>, MediaTypeList <chr>, Permalink <chr>, Domain <chr>,
#> #   Retweets <dbl>, `Tweet Generator` <chr>, Favorites <dbl>, …