0

Phrasal verb is really important in day-to-day English usage. Is there any library in R that allows us to deal with it? I have tried 2 ways but it seems unable to deal with it

For example

library(sentimentr)
library(tidytext)
library(tidyverse)

x <- 'i vomit when i see her'
y <- 'i throw up when i see her'

# sentimentR
sentiment(x) #give sentiment of -0.4
sentiment(y) #give sentiment of 0

# Similarly, using tidytext
y %>% as_tibble() %>% 
    unnest_tokens(word, value) %>% 
    left_join(get_sentiments('bing'))    # give all words the sentiments of 0

I came up with a (clumsy) strategy to deal with phrasal verbs:

# create a dummy phrasal verb sentiment score
phrasel_verb <- data.frame(bigram = c("throw up"), 
                           bigram_score = -1)

# use tidy text to make bigram--> join
y %>% as_tibble() %>% 
    unnest_tokens(bigram, value, 'ngrams', n = 2) %>% 
    separate(bigram, c('word','word2'), remove = F) %>% 
    left_join(phrasel_verb) %>% 
    left_join(get_sentiments('bing')) %>% 
    mutate(sentiment_all = coalesce(bigram_score, as.numeric(sentiment)))  %>% 
    summarise(sentiment_sum = sum(na.fill(sentiment_all, 0)))

The result is -1 which suggest a negative sentiments. Any ideas to improve it? Are there any data that have sentiment score of phrasal verb?

ducvu169
  • 103
  • 1
  • 12
  • 1
    I don't know of any ready-to-go datasets of phrasal verbs but this certainly is an interesting avenue for study. It's similar to the idea of [modals and negators](https://github.com/juliasilge/tidytext/blob/master/R/nma_words.R). – Julia Silge Apr 24 '18 at 18:29
  • Never thought that my question will be answered by tidytext creator! For negation, most of the time, we can use replace_contraction() from qdap to extract from words like , making it . Btw, I am writing an articles which combine your tidytext with other tools for text mining. Would you mind reading it and giving some recommendation? – ducvu169 Apr 26 '18 at 04:10
  • I am not 100% sure I can commit to review, but if you ping me on Twitter or GitHub, I may be able to give a look! – Julia Silge Apr 26 '18 at 17:10

0 Answers0