Purpose

In this subsection the tuplet (=output of the Stanford Parser) was transformed into a negation tag.

PREPROCESSING

1. Preparation

#install.packages("tokenizers")
#install.packages("FSelectorRcpp")
library(NLP)
library(FSelectorRcpp)
library(tokenizers)
## Warning: package 'tokenizers' was built under R version 3.4.4
library(tm)
## Warning: package 'tm' was built under R version 3.4.3
library(SnowballC)
library(stats)
library(ngram)
## Warning: package 'ngram' was built under R version 3.4.3
library(stringr)
library(readxl)
setwd("~/Google Drive/UM/Smart Services/Thesis/Thesis/Code/Feature Set3/Code/3. Negation Tagging")

IMPORT DATA

#Import Destination Text 
Destination.Text <- read_excel("~/Google Drive/UM/Smart Services/Thesis/Thesis/Code/Feature Set3/Input/2. Negative Fragments.xlsx")
Destination.Text <- Destination.Text$Neg.Text
Destination.Text <- as.character(Destination.Text)
Destination.Text <- removePunctuation(Destination.Text)
Destination.Text <- as.list(Destination.Text)
#Import Dependency Triplets
Tagged.Text <- read_excel("~/Google Drive/UM/Smart Services/Thesis/Thesis/Code/Feature Set3/Input/3.Negation Parsed Text.xlsx")
Tagged.Text <- Tagged.Text[-1]
Tagged.Text <- Tagged.Text$`0`
Tagged.Text <- as.list(Tagged.Text)
Tagged.Text <- gsub("\\]","",Tagged.Text)
Tagged.Text <- gsub("\\[","",Tagged.Text)
Tagged.Text <- strsplit(Tagged.Text,split = ",")
for(i in 1:420){
  Extract <- Tagged.Text[[i]]
  Length <- length(Extract)
  if(Length == 6){
    Extract <- list(Extract[3],Extract[6])
  }else if(Length ==9){
    Extract <- list(Extract[3],Extract[6],Extract[9])
  }else{
    Extract <- Extract[3]
  }
  Tagged.Text[[i]] <- Extract
}
Indeces <- list()
for(i in 1:420){
  Extract <- Tagged.Text[[i]]
  Length <- length(Extract)
  print(Extract)
  print(Length)
  if(Length == 2){
    Index <- as.list(rep(print(i),2))
  }else if(Length ==3){
    Index <- as.list(rep(print(i),3))
  }else{
    Index <- as.list(rep(print(i),1))
  }
  Indeces[[i]] <- Index
}
## [1] " 'one'"
## [1] 1
## [1] 1
## [1] " 'room'"
## [1] 1
## [1] 2
## [1] " 'closed'"
## [1] 1
## [1] 3
## [1] " 'stop'"
## [1] 1
## [1] 4
## [1] " 'attach'"
## [1] 1
## [1] 5
## [1] " 'able'"
## [1] 1
## [1] 6
## [1] " 'fridge'"
## [1] 1
## [1] 7
## [1] " 'cleaned'"
## [1] 1
## [1] 8
## [1] " 'respond'"
## [1] 1
## [1] 9
## [1] " 'bed'"
## [1] 1
## [1] 10
## [1] " 'change'"
## [1] 1
## [1] 11
## [1] " 'ready'"
## [1] 1
## [1] 12
## [1] " 'work'"
## [1] 1
## [1] 13
## [1] " 'safe'"
## [1] 1
## [1] 14
## [[1]]
## [1] " 'like'"
## 
## [[2]]
## [1] " 'included'"
## 
## [1] 2
## [1] 15
## [1] " 'handrail'"
## [1] 1
## [1] 16
## [1] " 'even'"
## [1] 1
## [1] 17
## [1] " 'cleaning'"
## [1] 1
## [1] 18
## [1] " 'try'"
## [1] 1
## [1] 19
## [1] NA
## [1] 1
## [1] 20
## [1] " 'interest'"
## [1] 1
## [1] 21
## [1] " 'greeted'"
## [1] 1
## [1] 22
## [1] " 'happy'"
## [1] 1
## [1] 23
## [1] " 'light'"
## [1] 1
## [1] 24
## [1] " 'handrail'"
## [1] 1
## [1] 25
## [1] " 'practical'"
## [1] 1
## [1] 26
## [1] " 'included'"
## [1] 1
## [1] 27
## [1] " 'mentioned'"
## [1] 1
## [1] 28
## [1] NA
## [1] 1
## [1] 29
## [1] " 'is'"
## [1] 1
## [1] 30
## [1] " 'have'"
## [1] 1
## [1] 31
## [1] NA
## [1] 1
## [1] 32
## [1] NA
## [1] 1
## [1] 33
## [1] NA
## [1] 1
## [1] 34
## [1] " 'qualified'"
## [1] 1
## [1] 35
## [1] NA
## [1] 1
## [1] 36
## [1] " 'drain'"
## [1] 1
## [1] 37
## [1] " 'longer'"
## [1] 1
## [1] 38
## [1] " 'rectified'"
## [1] 1
## [1] 39
## [1] " 'mentioned'"
## [1] 1
## [1] 40
## [1] " 'work'"
## [1] 1
## [1] 41
## [1] NA
## [1] 1
## [1] 42
## [[1]]
## [1] " 'able'"
## 
## [[2]]
## [1] " 'regulate'"
## 
## [1] 2
## [1] 43
## [1] " 'area'"
## [1] 1
## [1] 44
## [1] " 'existent'"
## [1] 1
## [1] 45
## [1] " 'turned'"
## [1] 1
## [1] 46
## [[1]]
## [1] " 'cooling'"
## 
## [[2]]
## [1] " 'thermostat'"
## 
## [1] 2
## [1] 47
## [[1]]
## [1] " 'replenished'"
## 
## [[2]]
## [1] " 'replenished'"
## 
## [1] 2
## [1] 48
## [1] " 'mentioned'"
## [1] 1
## [1] 49
## [1] " 'private'"
## [1] 1
## [1] 50
## [1] " 'honestly'"
## [1] 1
## [1] 51
## [1] " 'disruption'"
## [1] 1
## [1] 52
## [1] " 'feel'"
## [1] 1
## [1] 53
## [1] " 'leave'"
## [1] 1
## [1] 54
## [1] " 'closing'"
## [1] 1
## [1] 55
## [1] " 'stay'"
## [1] 1
## [1] 56
## [1] " 'just'"
## [1] 1
## [1] 57
## [1] " 'petals'"
## [1] 1
## [1] 58
## [[1]]
## [1] " 'expecting'"
## 
## [[2]]
## [1] " 'keen'"
## 
## [1] 2
## [1] 59
## [[1]]
## [1] " 'leaving'"
## 
## [[2]]
## [1] " 'sleep'"
## 
## [1] 2
## [1] 60
## [1] " 'floor'"
## [1] 1
## [1] 61
## [1] " 'connected'"
## [1] 1
## [1] 62
## [1] " 'cleaned'"
## [1] 1
## [1] 63
## [1] NA
## [1] 1
## [1] 64
## [1] NA
## [1] 1
## [1] 65
## [1] " 'indicated'"
## [1] 1
## [1] 66
## [1] " 'is'"
## [1] 1
## [1] 67
## [1] " 'money'"
## [1] 1
## [1] 68
## [1] " 'milk'"
## [1] 1
## [1] 69
## [1] NA
## [1] 1
## [1] 70
## [1] " 'warning'"
## [1] 1
## [1] 71
## [[1]]
## [1] " 'safe'"
## 
## [[2]]
## [1] " 'barrier'"
## 
## [1] 2
## [1] 72
## [1] " 'chain'"
## [1] 1
## [1] 73
## [1] " 'have'"
## [1] 1
## [1] 74
## [1] " 'big'"
## [1] 1
## [1] 75
## [1] " 'worry'"
## [1] 1
## [1] 76
## [1] " 'complants'"
## [1] 1
## [1] 77
## [1] " 'passed'"
## [1] 1
## [1] 78
## [1] " 'tours'"
## [1] 1
## [1] 79
## [1] " 'buy'"
## [1] 1
## [1] 80
## [1] " 'surroundings'"
## [1] 1
## [1] 81
## [1] NA
## [1] 1
## [1] 82
## [1] " 'star'"
## [1] 1
## [1] 83
## [1] " 'intrusive'"
## [1] 1
## [1] 84
## [1] " 'helpful'"
## [1] 1
## [1] 85
## [1] " 'place'"
## [1] 1
## [1] 86
## [[1]]
## [1] " 'though'"
## 
## [[2]]
## [1] " 'close'"
## 
## [1] 2
## [1] 87
## [1] " 'deducted'"
## [1] 1
## [1] 88
## [1] " 'mention'"
## [1] 1
## [1] 89
## [[1]]
## [1] " 'returning'"
## 
## [[2]]
## [1] " 'recommend'"
## 
## [1] 2
## [1] 90
## [1] " 'comfortable'"
## [1] 1
## [1] 91
## [[1]]
## [1] " 'provide'"
## 
## [[2]]
## [1] " 'suite'"
## 
## [1] 2
## [1] 92
## [1] " 'central'"
## [1] 1
## [1] 93
## [1] " 'shelf'"
## [1] 1
## [1] 94
## [1] NA
## [1] 1
## [1] 95
## [1] " 'provide'"
## [1] 1
## [1] 96
## [1] NA
## [1] 1
## [1] 97
## [1] " 'safe'"
## [1] 1
## [1] 98
## [1] " 'floor'"
## [1] 1
## [1] 99
## [1] " 'comfortable'"
## [1] 1
## [1] 100
## [1] " 'is'"
## [1] 1
## [1] 101
## [1] " 'frills'"
## [1] 1
## [1] 102
## [[1]]
## [1] " 'iron'"
## 
## [[2]]
## [1] " 'work'"
## 
## [1] 2
## [1] 103
## [1] " 'know'"
## [1] 1
## [1] 104
## [1] " 'liking'"
## [1] 1
## [1] 105
## [1] " 'consider'"
## [1] 1
## [1] 106
## [1] " 'impact'"
## [1] 1
## [1] 107
## [1] " 'ideal'"
## [1] 1
## [1] 108
## [1] NA
## [1] 1
## [1] 109
## [1] " 'business'"
## [1] 1
## [1] 110
## [1] NA
## [1] 1
## [1] 111
## [1] " 'is'"
## [1] 1
## [1] 112
## [1] NA
## [1] 1
## [1] 113
## [1] " 'have'"
## [1] 1
## [1] 114
## [[1]]
## [1] " 'clean'"
## 
## [[2]]
## [1] " 'sheets'"
## 
## [1] 2
## [1] 115
## [1] " 'couple'"
## [1] 1
## [1] 116
## [1] " 'practical'"
## [1] 1
## [1] 117
## [1] " 'money'"
## [1] 1
## [1] 118
## [1] " 'included'"
## [1] 1
## [1] 119
## [1] " 'hassle'"
## [1] 1
## [1] 120
## [1] " 'problem'"
## [1] 1
## [1] 121
## [1] " 'problem'"
## [1] 1
## [1] 122
## [1] " 'is'"
## [1] 1
## [1] 123
## [1] NA
## [1] 1
## [1] 124
## [1] " 'quality'"
## [1] 1
## [1] 125
## [1] " 'rooms'"
## [1] 1
## [1] 126
## [1] " 'depicted'"
## [1] 1
## [1] 127
## [1] NA
## [1] 1
## [1] 128
## [1] NA
## [1] 1
## [1] 129
## [1] " 'included'"
## [1] 1
## [1] 130
## [1] " 'mentioned'"
## [1] 1
## [1] 131
## [1] " 'park'"
## [1] 1
## [1] 132
## [1] " 'place'"
## [1] 1
## [1] 133
## [1] " 'listening'"
## [1] 1
## [1] 134
## [1] NA
## [1] 1
## [1] 135
## [1] " 'because'"
## [1] 1
## [1] 136
## [1] " 'want'"
## [1] 1
## [1] 137
## [1] " 'curtain'"
## [1] 1
## [1] 138
## [[1]]
## [1] " 'compensation'"
## 
## [[2]]
## [1] " 'enough'"
## 
## [1] 2
## [1] 139
## [1] NA
## [1] 1
## [1] 140
## [1] " 'have'"
## [1] 1
## [1] 141
## [1] " 'towels'"
## [1] 1
## [1] 142
## [1] " 'bothered'"
## [1] 1
## [1] 143
## [1] " 'allowed'"
## [1] 1
## [1] 144
## [1] " 'stayed'"
## [1] 1
## [1] 145
## [1] " 'said'"
## [1] 1
## [1] 146
## [1] " 'helpful'"
## [1] 1
## [1] 147
## [1] " 'expect'"
## [1] 1
## [1] 148
## [1] " 'think'"
## [1] 1
## [1] 149
## [1] " 'rest'"
## [1] 1
## [1] 150
## [1] " 'privacy'"
## [1] 1
## [1] 151
## [[1]]
## [1] " 'hoovered'"
## 
## [[2]]
## [1] " 'changed'"
## 
## [1] 2
## [1] 152
## [1] " 'experience'"
## [1] 1
## [1] 153
## [1] " 'cleaned'"
## [1] 1
## [1] 154
## [[1]]
## [1] " 'decor'"
## 
## [[2]]
## [1] " 'heard'"
## 
## [1] 2
## [1] 155
## [1] " 'mentioned'"
## [1] 1
## [1] 156
## [1] " 'hear'"
## [1] 1
## [1] 157
## [1] " 'exchanged'"
## [1] 1
## [1] 158
## [1] " 'keeping'"
## [1] 1
## [1] 159
## [1] " 'left'"
## [1] 1
## [1] 160
## [1] " 'shelf'"
## [1] 1
## [1] 161
## [1] NA
## [1] 1
## [1] 162
## [1] " 'rail'"
## [1] 1
## [1] 163
## [[1]]
## [1] " 'noisy'"
## 
## [[2]]
## [1] " 'at'"
## 
## [1] 2
## [1] 164
## [1] " 'issue'"
## [1] 1
## [1] 165
## [1] " 'nice'"
## [1] 1
## [1] 166
## [1] " 'used'"
## [1] 1
## [1] 167
## [1] " 'made'"
## [1] 1
## [1] 168
## [1] " 'changed'"
## [1] 1
## [1] 169
## [1] " 'light'"
## [1] 1
## [1] 170
## [1] " 'want'"
## [1] 1
## [1] 171
## [1] " 'toiletries'"
## [1] 1
## [1] 172
## [1] NA
## [1] 1
## [1] 173
## [1] " 'good'"
## [1] 1
## [1] 174
## [1] " 'working'"
## [1] 1
## [1] 175
## [[1]]
## [1] " 'cleaned'"
## 
## [[2]]
## [1] " 'cups'"
## 
## [[3]]
## [1] " 'replaced'"
## 
## [1] 3
## [1] 176
## [1] " 'taken'"
## [1] 1
## [1] 177
## [1] " 'advised'"
## [1] 1
## [1] 178
## [1] " 'park'"
## [1] 1
## [1] 179
## [1] NA
## [1] 1
## [1] 180
## [1] NA
## [1] 1
## [1] 181
## [1] " 'work'"
## [1] 1
## [1] 182
## [1] " 'renovation'"
## [1] 1
## [1] 183
## [1] " 'communicated'"
## [1] 1
## [1] 184
## [1] " 'accommodating'"
## [1] 1
## [1] 185
## [1] " 'find'"
## [1] 1
## [1] 186
## [1] NA
## [1] 1
## [1] 187
## [1] " 'privacy'"
## [1] 1
## [1] 188
## [1] " 'helpful'"
## [1] 1
## [1] 189
## [1] NA
## [1] 1
## [1] 190
## [1] " 'advertise'"
## [1] 1
## [1] 191
## [1] " 'smart'"
## [1] 1
## [1] 192
## [1] " 'best'"
## [1] 1
## [1] 193
## [1] " 'fan'"
## [1] 1
## [1] 194
## [1] " 'better'"
## [1] 1
## [1] 195
## [1] NA
## [1] 1
## [1] 196
## [1] NA
## [1] 1
## [1] 197
## [1] " 'worth'"
## [1] 1
## [1] 198
## [[1]]
## [1] " 'real'"
## 
## [[2]]
## [1] " 'tv'"
## 
## [1] 2
## [1] 199
## [1] " 'inspiring'"
## [1] 1
## [1] 200
## [[1]]
## [1] " 'available'"
## 
## [[2]]
## [1] " 'check'"
## 
## [[3]]
## [1] " 'acceptable'"
## 
## [1] 3
## [1] 201
## [[1]]
## [1] " 'more'"
## 
## [[2]]
## [1] " 'became'"
## 
## [1] 2
## [1] 202
## [1] " 'disgruntled'"
## [1] 1
## [1] 203
## [1] " 'recommend'"
## [1] 1
## [1] 204
## [1] NA
## [1] 1
## [1] 205
## [1] " 'mashine'"
## [1] 1
## [1] 206
## [1] " 'informed'"
## [1] 1
## [1] 207
## [1] " 'confident'"
## [1] 1
## [1] 208
## [1] " 'friendly'"
## [1] 1
## [1] 209
## [1] " 'used'"
## [1] 1
## [1] 210
## [1] " 'problem'"
## [1] 1
## [1] 211
## [1] " 'air'"
## [1] 1
## [1] 212
## [1] " 'safe'"
## [1] 1
## [1] 213
## [1] NA
## [1] 1
## [1] 214
## [1] " 'idea'"
## [1] 1
## [1] 215
## [1] " 'recommend'"
## [1] 1
## [1] 216
## [1] " 'complain'"
## [1] 1
## [1] 217
## [1] " 'eat'"
## [1] 1
## [1] 218
## [1] NA
## [1] 1
## [1] 219
## [1] NA
## [1] 1
## [1] 220
## [1] " 'problem'"
## [1] 1
## [1] 221
## [1] " 'spot'"
## [1] 1
## [1] 222
## [1] " 'mat'"
## [1] 1
## [1] 223
## [1] " 'allowed'"
## [1] 1
## [1] 224
## [1] " 'helpful'"
## [1] 1
## [1] 225
## [1] " 'have'"
## [1] 1
## [1] 226
## [[1]]
## [1] " 'have'"
## 
## [[2]]
## [1] " 'deal'"
## 
## [1] 2
## [1] 227
## [1] " 'get'"
## [1] 1
## [1] 228
## [1] " 'found'"
## [1] 1
## [1] 229
## [1] " 'good'"
## [1] 1
## [1] 230
## [1] " 'view'"
## [1] 1
## [1] 231
## [1] " 'replenished'"
## [1] 1
## [1] 232
## [1] " 'heated'"
## [1] 1
## [1] 233
## [1] " 'Pillows'"
## [1] 1
## [1] 234
## [1] " 'issues'"
## [1] 1
## [1] 235
## [1] " 'explanation'"
## [1] 1
## [1] 236
## [1] " 'helpful'"
## [1] 1
## [1] 237
## [1] NA
## [1] 1
## [1] 238
## [1] " 'outstanding'"
## [1] 1
## [1] 239
## [1] " 'warm'"
## [1] 1
## [1] 240
## [1] " 'make'"
## [1] 1
## [1] 241
## [1] " 'get'"
## [1] 1
## [1] 242
## [1] " 'impressive'"
## [1] 1
## [1] 243
## [1] " 'what'"
## [1] 1
## [1] 244
## [1] " 'extras'"
## [1] 1
## [1] 245
## [1] " 'upgrade'"
## [1] 1
## [1] 246
## [1] NA
## [1] 1
## [1] 247
## [1] " 'had'"
## [1] 1
## [1] 248
## [1] NA
## [1] 1
## [1] 249
## [[1]]
## [1] " 'shut'"
## 
## [[2]]
## [1] " 'happening'"
## 
## [1] 2
## [1] 250
## [1] " 'work'"
## [1] 1
## [1] 251
## [1] " 'working'"
## [1] 1
## [1] 252
## [1] " 'empty'"
## [1] 1
## [1] 253
## [1] " 'room'"
## [1] 1
## [1] 254
## [1] NA
## [1] 1
## [1] 255
## [1] " 'basement'"
## [1] 1
## [1] 256
## [1] " 'used'"
## [1] 1
## [1] 257
## [1] " 'hotel'"
## [1] 1
## [1] 258
## [1] NA
## [1] 1
## [1] 259
## [1] " 'space'"
## [1] 1
## [1] 260
## [1] " 'quality'"
## [1] 1
## [1] 261
## [1] " 'reccomended'"
## [1] 1
## [1] 262
## [1] " 'cleaned'"
## [1] 1
## [1] 263
## [1] " 'conditioning'"
## [1] 1
## [1] 264
## [1] " 'thick'"
## [1] 1
## [1] 265
## [1] " 'close'"
## [1] 1
## [1] 266
## [1] " 'bars'"
## [1] 1
## [1] 267
## [[1]]
## [1] " 'need'"
## 
## [[2]]
## [1] " 'heard'"
## 
## [1] 2
## [1] 268
## [1] NA
## [1] 1
## [1] 269
## [1] " 'screen'"
## [1] 1
## [1] 270
## [1] " 'brewing'"
## [1] 1
## [1] 271
## [1] " 'cooked'"
## [1] 1
## [1] 272
## [1] " 'lower'"
## [1] 1
## [1] 273
## [1] " 'reached'"
## [1] 1
## [1] 274
## [1] " 'instructions'"
## [1] 1
## [1] 275
## [1] " 'direction'"
## [1] 1
## [1] 276
## [1] " 'issue'"
## [1] 1
## [1] 277
## [1] " 'set'"
## [1] 1
## [1] 278
## [1] " 'interested'"
## [1] 1
## [1] 279
## [1] " 'sleep'"
## [1] 1
## [1] 280
## [1] " 'helpful'"
## [1] 1
## [1] 281
## [1] " 'work'"
## [1] 1
## [1] 282
## [1] " 'bar'"
## [1] 1
## [1] 283
## [1] " 'anymore'"
## [1] 1
## [1] 284
## [1] " 'able'"
## [1] 1
## [1] 285
## [1] " 'reply'"
## [1] 1
## [1] 286
## [1] " 'sure'"
## [1] 1
## [1] 287
## [1] " 'next'"
## [1] 1
## [1] 288
## [1] " 'reply'"
## [1] 1
## [1] 289
## [1] " 'idea'"
## [1] 1
## [1] 290
## [1] NA
## [1] 1
## [1] 291
## [1] " 'trained'"
## [1] 1
## [1] 292
## [1] " 'open'"
## [1] 1
## [1] 293
## [1] " 'count'"
## [1] 1
## [1] 294
## [1] NA
## [1] 1
## [1] 295
## [1] " 'windows'"
## [1] 1
## [1] 296
## [1] " 'rushed'"
## [1] 1
## [1] 297
## [1] " 'deal'"
## [1] 1
## [1] 298
## [1] " 'cooling'"
## [1] 1
## [1] 299
## [1] " 'obvious'"
## [1] 1
## [1] 300
## [1] " 'experience'"
## [1] 1
## [1] 301
## [1] " 'friendly'"
## [1] 1
## [1] 302
## [[1]]
## [1] " 'available'"
## 
## [[2]]
## [1] " 'focussed'"
## 
## [1] 2
## [1] 303
## [1] " 'way'"
## [1] 1
## [1] 304
## [[1]]
## [1] " 'cooked'"
## 
## [[2]]
## [1] " 'dish'"
## 
## [1] 2
## [1] 305
## [[1]]
## [1] " 'wine'"
## 
## [[2]]
## [1] " 'nesepresso'"
## 
## [1] 2
## [1] 306
## [1] " 'breakfast'"
## [1] 1
## [1] 307
## [1] " 'big'"
## [1] 1
## [1] 308
## [1] " 'duting'"
## [1] 1
## [1] 309
## [1] " 'is'"
## [1] 1
## [1] 310
## [1] NA
## [1] 1
## [1] 311
## [1] " 'work'"
## [1] 1
## [1] 312
## [1] " 'ready'"
## [1] 1
## [1] 313
## [1] " 'have'"
## [1] 1
## [1] 314
## [1] " 'care'"
## [1] 1
## [1] 315
## [1] " 'replenished'"
## [1] 1
## [1] 316
## [1] " 'big'"
## [1] 1
## [1] 317
## [1] NA
## [1] 1
## [1] 318
## [1] " 'facilities'"
## [1] 1
## [1] 319
## [1] " 'receive'"
## [1] 1
## [1] 320
## [1] " 'taste'"
## [1] 1
## [1] 321
## [1] NA
## [1] 1
## [1] 322
## [1] " 'happier'"
## [1] 1
## [1] 323
## [1] " 'hotel'"
## [1] 1
## [1] 324
## [1] NA
## [1] 1
## [1] 325
## [1] " 'sugar'"
## [1] 1
## [1] 326
## [1] " 'noisy'"
## [1] 1
## [1] 327
## [1] " 'first'"
## [1] 1
## [1] 328
## [[1]]
## [1] " 'help'"
## 
## [[2]]
## [1] " 'morning'"
## 
## [[3]]
## [1] " 'was'"
## 
## [1] 3
## [1] 329
## [1] " 'work'"
## [1] 1
## [1] 330
## [1] " 'promoted'"
## [1] 1
## [1] 331
## [1] " 'retain'"
## [1] 1
## [1] 332
## [1] " 'problem'"
## [1] 1
## [1] 333
## [1] " 'work'"
## [1] 1
## [1] 334
## [1] " 'comfortable'"
## [1] 1
## [1] 335
## [1] " 'was'"
## [1] 1
## [1] 336
## [1] " 'good'"
## [1] 1
## [1] 337
## [1] " 'the'"
## [1] 1
## [1] 338
## [[1]]
## [1] " 'condition'"
## 
## [[2]]
## [1] " 'working'"
## 
## [1] 2
## [1] 339
## [1] " 'expensive'"
## [1] 1
## [1] 340
## [1] " 'restaurants'"
## [1] 1
## [1] 341
## [1] " 'needed'"
## [1] 1
## [1] 342
## [1] " 'parking'"
## [1] 1
## [1] 343
## [1] " 'cleaning'"
## [1] 1
## [1] 344
## [[1]]
## [1] " 'facilities'"
## 
## [[2]]
## [1] " 'staying'"
## 
## [1] 2
## [1] 345
## [1] " 'use'"
## [1] 1
## [1] 346
## [1] " 'big'"
## [1] 1
## [1] 347
## [1] " 'have'"
## [1] 1
## [1] 348
## [1] " 'value'"
## [1] 1
## [1] 349
## [1] NA
## [1] 1
## [1] 350
## [1] " 'heard'"
## [1] 1
## [1] 351
## [1] " 'recommend'"
## [1] 1
## [1] 352
## [1] " 'processed'"
## [1] 1
## [1] 353
## [1] " 'stay'"
## [1] 1
## [1] 354
## [1] " 'division'"
## [1] 1
## [1] 355
## [1] " 'want'"
## [1] 1
## [1] 356
## [1] " 'best'"
## [1] 1
## [1] 357
## [1] " 'dropped'"
## [1] 1
## [1] 358
## [1] " 'provide'"
## [1] 1
## [1] 359
## [1] " 'received'"
## [1] 1
## [1] 360
## [1] NA
## [1] 1
## [1] 361
## [1] " 'tables'"
## [1] 1
## [1] 362
## [1] " '6'"
## [1] 1
## [1] 363
## [1] " 'afford'"
## [1] 1
## [1] 364
## [1] " 'way'"
## [1] 1
## [1] 365
## [1] " 'acknowledgement'"
## [1] 1
## [1] 366
## [1] " 'a'"
## [1] 1
## [1] 367
## [1] " 'ventilation'"
## [1] 1
## [1] 368
## [1] " 'informed'"
## [1] 1
## [1] 369
## [1] " 'insolation'"
## [1] 1
## [1] 370
## [1] " 'bath'"
## [1] 1
## [1] 371
## [1] " 'stayed'"
## [1] 1
## [1] 372
## [1] " 'cleaned'"
## [1] 1
## [1] 373
## [1] " 'good'"
## [1] 1
## [1] 374
## [1] " 'brand'"
## [1] 1
## [1] 375
## [1] " 'atttentive'"
## [1] 1
## [1] 376
## [1] " 'close'"
## [1] 1
## [1] 377
## [1] " 'big'"
## [1] 1
## [1] 378
## [1] " 'working'"
## [1] 1
## [1] 379
## [1] " 'stay'"
## [1] 1
## [1] 380
## [1] " 'treatment'"
## [1] 1
## [1] 381
## [1] " 'like'"
## [1] 1
## [1] 382
## [1] " 'longer'"
## [1] 1
## [1] 383
## [1] " 'working'"
## [1] 1
## [1] 384
## [1] " 'fresh'"
## [1] 1
## [1] 385
## [1] " 'fault'"
## [1] 1
## [1] 386
## [1] " 'outlook'"
## [1] 1
## [1] 387
## [1] " 'comfortable'"
## [1] 1
## [1] 388
## [1] " 'enough'"
## [1] 1
## [1] 389
## [1] NA
## [1] 1
## [1] 390
## [1] " 'going'"
## [1] 1
## [1] 391
## [1] " 'holiday'"
## [1] 1
## [1] 392
## [1] " 'bath'"
## [1] 1
## [1] 393
## [1] " 'Heating'"
## [1] 1
## [1] 394
## [1] " 'suitable'"
## [1] 1
## [1] 395
## [1] " 'me'"
## [1] 1
## [1] 396
## [1] " 'bath'"
## [1] 1
## [1] 397
## [1] " 'helpful'"
## [1] 1
## [1] 398
## [1] " 'room'"
## [1] 1
## [1] 399
## [1] " 'Breakfast'"
## [1] 1
## [1] 400
## [1] " 'everything'"
## [1] 1
## [1] 401
## [1] " 'space'"
## [1] 1
## [1] 402
## [1] " 'acceptable'"
## [1] 1
## [1] 403
## [1] " 'comfortable'"
## [1] 1
## [1] 404
## [1] " 'negatives'"
## [1] 1
## [1] 405
## [1] " 'great'"
## [1] 1
## [1] 406
## [1] " 'buy'"
## [1] 1
## [1] 407
## [1] " 'have'"
## [1] 1
## [1] 408
## [1] " 'done'"
## [1] 1
## [1] 409
## [1] " 'came'"
## [1] 1
## [1] 410
## [1] " 'eat'"
## [1] 1
## [1] 411
## [1] " 'far'"
## [1] 1
## [1] 412
## [1] " 'bad'"
## [1] 1
## [1] 413
## [[1]]
## [1] " 'seal'"
## 
## [[2]]
## [1] " 'couple'"
## 
## [1] 2
## [1] 414
## [1] " 'work'"
## [1] 1
## [1] 415
## [1] " 'get'"
## [1] 1
## [1] 416
## [1] " 'options'"
## [1] 1
## [1] 417
## [1] " 'easy'"
## [1] 1
## [1] 418
## [1] " 'slept'"
## [1] 1
## [1] 419
## [1] NA
## [1] 1
## [1] 420
df <- data.frame(unlist(Indeces), unlist(Tagged.Text)) 
colnames(df) <- c("ID","Words")

Comparison with Negative Fragments shows that the splitting was successful.

Cleaned.Tagged.Text <- subset(df,is.na(Words)==FALSE)

TRANSFORM WORDS

Replacement Word

Replace.Word <- as.character(Cleaned.Tagged.Text$Words)
Replace.Word <- gsub("\\'","",Replace.Word)
Replace.Word <- stripWhitespace(Replace.Word)
Replace.Word <- gsub(" ","",Replace.Word)
Replace.Word <- as.list(Replace.Word)
Replace.Word.Transformed <- list()

for (j in 1:404){
  Extract <- Replace.Word[[j]]
  ADD1 <- "^"
  ADD2 <- "$"
  Transformed <- paste(ADD1,Extract,ADD2,sep = "")
  Replace.Word.Transformed[[j]] <- Transformed
}
Cleaned.Tagged.Text$Words <- Replace.Word.Transformed

Tagged Word

#PreTagging
TaggedWord <- Replace.Word

for(k in 1:404){
  Word <- TaggedWord[[k]]
  Word <- stemDocument(Word)
  ADD <- "_NOT"
  New_Word <- paste(Word,ADD,collapse = '')
  TaggedWord[[k]] <- New_Word
}
for (l in 1:404){
  Extract <- TaggedWord[[l]]
  Extract <- gsub(" \\_", "\\_",Extract)
  TaggedWord[[l]] <- Extract
}
Cleaned.Tagged.Text$TaggedWord <- TaggedWord

TAGG WORDS

NegationTagged <- Destination.Text

for (m in 1:404){
  ID <- Cleaned.Tagged.Text$ID[[m]]
  Word <- Cleaned.Tagged.Text$Words[[m]]
  NewWord <- Cleaned.Tagged.Text$TaggedWord[[m]]
  
  Sentence <- Destination.Text[[ID]]
  Words <- strsplit(Sentence,split = " ")
  Words <- unlist(Words)
  Words <- as.list(Words)
  Word.ID <- grep(Word,Words)
  Word.ID <- Word.ID[1]
  
  Words[[Word.ID]] <- NewWord
  Sentence <- paste(Words,collapse = ' ')

  NegationTagged[[ID]] <- Sentence
}

NegationTagged[[67]]
## [1] "The hotel is_NOT not in the centre however is a walkable distance or easily got to by the"
NegationTagged <- as.character(NegationTagged)

REMOVE NEGATIONS

#Get List of Negations
library(qdapDictionaries)
## Warning: package 'qdapDictionaries' was built under R version 3.4.4
Negations <- as.list(qdapDictionaries::negation.words)

Length2 <- as.numeric(length(Negations))
Negations.Clean <- as.list(rep(NA,Length2))

for (j in 1:Length2){
  Extract <- Negations[[j]]
  Extract <-gsub("'"," ",Extract)
  Negations.Clean[[j]] <- Extract
}
Negations.Clean[[24]] <- "was t"
Negations.Clean[[25]] <- "did t"
Negations.Clean[[26]] <- "can t"
Negations.Clean <- as.character(Negations.Clean)
NegationTagged.Clean <- removeWords(NegationTagged,Negations.Clean)
NegationTagged.Clean <- stripWhitespace(NegationTagged.Clean)
NegationTagged.Clean <- as.list(NegationTagged.Clean)

NegationTagged.Clean[[1]]
## [1] "I am so angry that i made this post available via all possible sites i use when planing my trips so one_NOT will make the mistake of booking this place"
df <- data.frame(matrix(seq(1:420),nrow=420,ncol=1))
df$Tagged <- NegationTagged.Clean

EXPORT

WriteXLS::WriteXLS(df,ExcelFileName = "4.Negation Tagged.xlsx")