replace_rating: Replace Ratings With Words

Description Usage Arguments Value Examples

Description

Replaces ratings with word equivalents.

Usage

1
replace_rating(x, rating_dt = lexicon::key_rating, ...)

Arguments

x

The text variable.

rating_dt

A data.table of ratings and corresponding word meanings.

...

ignored.

Value

Returns a vector of strings with ratings replaced with word equivalents.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x <- c("This place receives 5 stars for their APPETIZERS!!!",
     "Four stars for the food & the guy in the blue shirt for his great vibe!",
     "10 out of 10 for both the movie and trilogy.",
     "* Both the Hot & Sour & the Egg Flower Soups were absolutely 5 Stars!",
     "For service, I give them no stars.", "This place deserves no stars.",
     "10 out of 10 stars.",
     "My rating: just 3 out of 10.",
     "If there were zero stars I would give it zero stars.",
     "Rating: 1 out of 10.",
     "I gave it 5 stars because of the sound quality.",
     "If it were possible to give them 0/10, they'd have it."
)

replace_rating(x)

Example output

 [1] "This place receives best for their APPETIZERS!!!"                    
 [2] " better for the food & the guy in the blue shirt for his great vibe!"
 [3] " best for both the movie and trilogy."                               
 [4] "* Both the Hot & Sour & the Egg Flower Soups were absolutely best !" 
 [5] "For service, I give them terrible ."                                 
 [6] "This place deserves terrible ."                                      
 [7] " best stars."                                                        
 [8] "My rating: just below average ."                                     
 [9] "If there were terrible I would give it terrible ."                   
[10] "Rating: extremely below average ."                                   
[11] "I gave it best because of the sound quality."                        
[12] "If it were possible to give them terrible , they'd have it."         

textclean documentation built on May 2, 2019, 7:22 a.m.