In this step, the Attenuator tagged words were reinserted into the review text.
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/2.Attenuator/4. Processing")
#Attenuator Tagging
AttenuatorTagged <- read_excel("~/Google Drive/UM/Smart Services/Thesis/Thesis/Code/Feature Set4/Input/8.AttenuatorTagged.xlsx")
AttenuatorTagged <- AttenuatorTagged$Text
AttenuatorTagged <- as.list(AttenuatorTagged)
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/6. Attenuator Sentence Indicators.xlsx")
Final.Sentence.ID <- as.list(Indeces$Attenuator.Index.List)
#DESTINATION TEXT
Destination.Text <- read_excel("~/Google Drive/UM/Smart Services/Thesis/Thesis/Code/Feature Set4/Input/5.Reviews with Booster Tagging.xlsx")
Destination.Text <- Destination.Text$BoosterTaggedReviews
Destination.Control <- Destination.Text
for (n in 1:623){
ID <- Final.Sentence.ID[[n]]
Text <- AttenuatorTagged[[n]]
Destination.Text[[ID]] <- Text
}
Destination.Text <- as.list(Destination.Text)
print('Old')
## [1] "Old"
Destination.Control [[36]]
## [1] "On a day with heavy rainfall a pretty common occurrence in ."
print('New')
## [1] "New"
Destination.Text [[36]]
## [1] "On a day with heavy rainfall a common_LOW occurrence in ."
df <- data.frame(matrix(data = seq(1,4735),nrow = 4735,ncol = 1))
df$AttenuatorTaggedReviews <- Destination.Text
WriteXLS::WriteXLS(df,ExcelFileName = "9.Reviews with Booster and Attenuator Tagging.xlsx")