Loading 02_code/R/Script 2 - Sentiment analysis.R +25 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ load("D:/Hohenheim/SEM 3/ADS/introads_ass2_team18/01_data/reviews.clean.RData") load("D:/Hohenheim/SEM 3/ADS/introads_ass2_team18/01_data/raw/gamereviews.RData") # Only keeping necessary columns for analysis rev.sentiment <- data.frame(reviews = reviews.clean$reviews) rev.sentiment <- data.frame(id= reviews.clean$recommendationid, reviews = reviews.clean$reviews) # Manual sentiment analysis----------------------------------------------------- Loading Loading @@ -161,3 +161,27 @@ cat("An emotion with highest weightage is positive with", round(nrc.scores$weigh cat("An emotion with highest weightage is disgust with", round(nrc.scores$weightage[10],2),"%\n") # Checking the consistency of sentiment with positive and negative voted_up merged <- merge(sent.label= rev.sentiment$sent.label, voted_up= gamereviews$voted_up, by.x = "id", by.y = "recommendationid", all.x = TRUE) comparison <- data.frame(id = merged$id, reviews = merged$reviews, sent.label=merged$sent.label, voted_up=merged$voted_up) comparison <- comparison %>% mutate(voted_up_mapped = case_when( voted_up==TRUE ~ "Positive", voted_up==FALSE ~ "Negative")) comparison$compare <- ifelse(comparison$sent.label == "Positive" & comparison$voted_up_mapped == "Positive", "positive", ifelse(comparison$sent.label == "Negative" & comparison$voted_up_mapped == "Negative", "positive", "Neutral")) # Counting the number of match match.count <- sum(comparison$compare=="Match") mismatch.count <- sum(comparison$compare=="Mismatch") total.count <- length(comparison$compare) # Calculating ration of match and mismatch match.ratio <- match.count / total.count # Display the result print(comparison_result) Loading
02_code/R/Script 2 - Sentiment analysis.R +25 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ load("D:/Hohenheim/SEM 3/ADS/introads_ass2_team18/01_data/reviews.clean.RData") load("D:/Hohenheim/SEM 3/ADS/introads_ass2_team18/01_data/raw/gamereviews.RData") # Only keeping necessary columns for analysis rev.sentiment <- data.frame(reviews = reviews.clean$reviews) rev.sentiment <- data.frame(id= reviews.clean$recommendationid, reviews = reviews.clean$reviews) # Manual sentiment analysis----------------------------------------------------- Loading Loading @@ -161,3 +161,27 @@ cat("An emotion with highest weightage is positive with", round(nrc.scores$weigh cat("An emotion with highest weightage is disgust with", round(nrc.scores$weightage[10],2),"%\n") # Checking the consistency of sentiment with positive and negative voted_up merged <- merge(sent.label= rev.sentiment$sent.label, voted_up= gamereviews$voted_up, by.x = "id", by.y = "recommendationid", all.x = TRUE) comparison <- data.frame(id = merged$id, reviews = merged$reviews, sent.label=merged$sent.label, voted_up=merged$voted_up) comparison <- comparison %>% mutate(voted_up_mapped = case_when( voted_up==TRUE ~ "Positive", voted_up==FALSE ~ "Negative")) comparison$compare <- ifelse(comparison$sent.label == "Positive" & comparison$voted_up_mapped == "Positive", "positive", ifelse(comparison$sent.label == "Negative" & comparison$voted_up_mapped == "Negative", "positive", "Neutral")) # Counting the number of match match.count <- sum(comparison$compare=="Match") mismatch.count <- sum(comparison$compare=="Mismatch") total.count <- length(comparison$compare) # Calculating ration of match and mismatch match.ratio <- match.count / total.count # Display the result print(comparison_result)