PREPARATION

1. Preparation

library(readxl)
library(NLP)
library(tm)
## Warning: package 'tm' was built under R version 3.4.3
library(stringr)
library(ngram)
## Warning: package 'ngram' was built under R version 3.4.3
setwd("~/Google Drive/UM/Smart Services/Thesis/Thesis/Code/Feature Set4/Code/1.Booster/4. Processing")

REINSERT TEXT INTO REVIEW

2. Load Data (Tagged Fragments)

#Booster Tagging
BoosterTagged <- read_excel("~/Google Drive/UM/Smart Services/Thesis/Thesis/Code/Feature Set4/Input/4.BoosterTagged.xlsx")
BoosterTagged <- BoosterTagged$Text
BoosterTagged <- as.list(BoosterTagged)

3. Load Data (IDs)

Using the Review and Sentence ID, the negated sentences will be reinserted into the review text.

Indeces <- read_excel("~/Google Drive/UM/Smart Services/Thesis/Thesis/Code/Feature Set4/Input/2. Booster Sentence Indicators.xlsx")

Final.Sentence.ID <- as.list(Indeces$Booster.Index.List)

4. Load Data (Destination Text)

#DESTINATION TEXT
Destination.Text <- read_excel("~/Google Drive/UM/Smart Services/Thesis/Thesis/Code/Feature Set4/Input/1.Reviews with Negation Tagging.xlsx")

Destination.Text <-Destination.Text$Tagged
Destination.Text <- as.list(Destination.Text)

5. Reinsert Negative Sentences into Review

Destination.Control <- Destination.Text
for (n in 1:516){
  ID <- Final.Sentence.ID[[n]]
  Text <- BoosterTagged[[n]]
  Destination.Text[[ID]] <- Text
}
print('Old')
## [1] "Old"
Destination.Control[[52]]
## [1] "Which was completely false advertising ."
print('New')
## [1] "New"
Destination.Text[[52]]
## [1] "Which was fals_HIGH advertising ."

EXPORT DATA

df <- data.frame(matrix(data = seq(1,4735),nrow = 4735,ncol = 1))
df$BoosterTaggedReviews <- Destination.Text
WriteXLS::WriteXLS(df,ExcelFileName = "5.Reviews with Booster Tagging.xlsx")