SENTIMENT ANALYSIS ON PM NARENDRA MODI’S SPEECH

In this Project we are up to find the sentiment nature of the comment that are given by the public on the Yutube platform By our Hounrable Prime Minister Narendra Modi ON MAY 12 2020.

Required Library

library(vosonSML)
library(syuzhet)
library(magrittr)

##Key from the google api

Gathering vedio file

youtubeVideoIds <- GetYoutubeVideoIDs(c("https://youtu.be/3gf4wqTLIvc"
                                        ))
## Extracted 1 video ids.

Collecting reqiured information from youtube

youtubeData <- youtubeAuth %>%
  Collect(videoIDs = youtubeVideoIds,
          maxComments = 400,
          verbose = FALSE)
## Collecting comment threads for youtube videos...
## Video 1 of 1
## ---------------------------------------------------------------
## ** video Id: 3gf4wqTLIvc
## ** Collected threads: 121
## ** Collecting replies for 30 threads with replies. Please be patient.
## ..............................
## ** Collected replies: 71
## ** Total video comments: 192
## ---------------------------------------------------------------
## ** Total comments collected for all videos 192.
## (Estimated API unit cost: 66)
## Done.

Summary from the youtubeData

activityNetwork <- youtubeData %>% Create("activity") %>% Graph() %>% summary()
## Generating youtube activity network...
## -------------------------
## collected youtube comments | 192
## top-level comments         | 121
## reply comments             | 71
## videos                     | 1 
## nodes                      | 193
## edges                      | 192
## -------------------------
## Done.
## Creating igraph network graph...Done.
## IGRAPH 3ef7c76 DN-- 193 192 -- 
## + attr: type (g/c), name (v/c), video_id (v/c), published_at (v/c),
## | updated_at (v/c), author_id (v/c), screen_name (v/c), node_type
## | (v/c), label (v/c), edge_type (e/c)

Converting the command into Human readable format

comments <- iconv(youtubeData$Comment , to = 'utf-8')

s <- get_nrc_sentiment(comments)
## Warning: `filter_()` is deprecated as of dplyr 0.7.0.
## Please use `filter()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
## Warning: `group_by_()` is deprecated as of dplyr 0.7.0.
## Please use `group_by()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
## Warning: `data_frame()` is deprecated as of tibble 1.1.0.
## Please use `tibble()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
youtubeData
## # A tibble: 192 x 12
##    Comment AuthorDisplayNa~ AuthorProfileIm~ AuthorChannelUrl AuthorChannelID
##    <chr>   <chr>            <chr>            <chr>            <chr>          
##  1 "Disli~ Best video whic~ https://yt3.ggp~ http://www.yout~ UC8p3BSA7dRn7H~
##  2 "Modi ~ Best video whic~ https://yt3.ggp~ http://www.yout~ UC8p3BSA7dRn7H~
##  3 "Sun k~ Govind Prasad    https://yt3.ggp~ http://www.yout~ UCVXRCvoFOc5e4~
##  4 "Time ~ engineer umar    https://yt3.ggp~ http://www.yout~ UCtjdTu0tijefL~
##  5 "I sug~ engineer umar    https://yt3.ggp~ http://www.yout~ UCtjdTu0tijefL~
##  6 "Aemet~ Jalndhara dalab~ https://yt3.ggp~ http://www.yout~ UCa3vR7Ye2pLQM~
##  7 "<U+0906><U+0917><U+0947> <U+0928>~  Raj hiwale       https://yt3.ggp~ http://www.yout~ UCOiGCb3-xXWB1~
##  8 "Aur K~ nii Night        https://yt3.ggp~ http://www.yout~ UC5sfUvOfxy_3H~
##  9 "Kutyy~ Asif Prince      https://yt3.ggp~ http://www.yout~ UC0nUib07yo0Hr~
## 10 "Dog s~ Asif Prince      https://yt3.ggp~ http://www.yout~ UC0nUib07yo0Hr~
## # ... with 182 more rows, and 7 more variables: ReplyCount <chr>,
## #   LikeCount <chr>, PublishedAt <chr>, UpdatedAt <chr>, CommentID <chr>,
## #   ParentID <chr>, VideoID <chr>

Representing the details in the barplot

barplot(100*colSums(s)/sum(s),
las = 2,
col = rainbow(10),
ylab ='Precentage(%)',
main = "Sentiment Analysis on Honourable PM MODI's Speech On 12 May 2020")