title: Problem while doing Tri-gram documents are mixing up with each other
body: <p><strong>Problem statement</strong></p>
  
  <p>While calculating tri-gram of text documents are mixing  up with from one another. </p>
  
  <p>I am trying get each individual values of dataframe row and applying trigram for only that document, but not able to do.</p>
  
  <p><strong>input data 1:</strong></p>
  
  <pre><code>subject_lines
  Need to make 'Address1' field mandatory in 'Leads'
  No display of record in "All Opportunities" Saved Search list
  "Organization" in Activity resources display name of a user
  </code></pre>
  
  <p>Below is my code to calculate tri-gram and its frequency across document</p>
  
  <pre><code>#Text Analysis for Oracle Fusion Sales Cloud Service data 
  library(lubridate)
  library(tm)
  library(SnowballC)
  library(RColorBrewer)
  library(wordcloud)
  library(RWeka)
  library(gsubfn)
  library(sqldf)
  
  #import the data in csv format
  EmailSubject_Dataset &lt;- read.csv("D:/TextAnalysisPOC_MasterPet/OracleFusionSalesCloudService_SampleDataset.csv", header=TRUE, sep=",")
  #corpus creation
  documents &lt;- Corpus(VectorSource(EmailSubject_Dataset$Subject.lines))
  
  # Data preprocessing 
  documents &lt;- tm_map(documents, content_transformer(tolower))
  documents &lt;- tm_map(documents, removePunctuation)
  documents &lt;- tm_map(documents, stripWhitespace)
  stopwordList &lt;- c('i', 'me', 'my', 'myself', 'we', 'our', 'ours', 'ourselves', 'you', "you're", "you've", "you'll", "you'd", 'your', 'yours', 'yourself', 'yourselves', 'he', 'him', 'his', 'himself', 'she', "she's", 'her', 'hers', 'herself', 'it', "it's", 'its', 'itself', 'they', 'them', 'their', 'theirs', 'themselves', 'what', 'which', 'who', 'whom', 'this', 'that', "that'll", 'these', 'those', 'am', 'is', 'are', 'was', 'were', 'be', 'been', 'being', 'have', 'has', 'had', 'having', 'do', 'does', 'did', 'doing', 'a', 'an', 'the', 'and', 'but', 'if', 'or', 'because', 'as', 'until', 'while', 'of', 'at', 'by', 'for', 'with', 'about', 'against', 'between', 'into', 'through', 'during', 'before', 'after', 'above', 'below', 'to', 'from', 'up', 'down', 'in', 'out', 'on', 'off', 'over', 'under', 'again', 'further', 'then', 'once', 'here', 'there', 'when', 'where', 'why', 'how', 'all', 'any', 'both', 'each', 'few', 'more', 'most', 'other', 'some', 'such', 'no', 'nor','only', 'own', 'same', 'so', 'than', 'too', 'very', 's', 't', 'can', 'will', 'just', 'don', "don't", 'should', "should've", 'now', 'd', 'll', 'm', 'o', 're', 've', 'y', 'ain', 'aren', "aren't", 'couldn', "couldn't", 'didn', "didn't", 'doesn', "doesn't", 'hadn', "hadn't", 'hasn', "hasn't", 'haven', "haven't", 'isn', "isn't", 'ma', 'mightn', "mightn't", 'mustn', "mustn't", 'needn', "needn't", 'shan', "shan't", 'shouldn', "shouldn't", 'wasn', "wasn't", 'weren', "weren't", 'won', "won't", 'wouldn', "wouldn't")
  documents &lt;- tm_map(documents, removeWords, stopwordList)
  reservedM&lt;-c("if","for","function","else","repeat","next","TRUE","from")
  documents &lt;- tm_map(documents, removeWords, reservedM)
  unwantedwordlist &lt;- c("prod caej","add","iuf","caej","iwf","iwf iuf","make","xxx","iwfcrmrupgrade","ccbo","ceo","ie","ruf","csf","osc","sr","moo","etc","see","jbojbo","lov","isn","hcm","oim","th","jbo","sha","adf","sui","re","oim","outlook","r","rel","via","abhishek")
  documents &lt;- tm_map(documents, removeWords, unwantedwordlist)
  #documents &lt;- tm_map(documents, removeWords, stopwords("english"))
  #documents = gsub('[[:punct:]]', '', documents)
  documents &lt;- tm_map(documents, stripWhitespace)
  #minfreq_bigram&lt;-2
  
  #Bi-gram implemetation
  token_delim &lt;- " \\t\\r\\n.!?,;\"()"
  tritoken &lt;- NGramTokenizer(documents, Weka_control(min=3,max=3, delimiters = token_delim))
  three_word &lt;- data.frame(table(tritoken))
  
  # Bi-gram frequency
  sort_threee &lt;- three_word[order(three_word$Freq),]
  head(sort_threee)
  sort_three &lt;- as.data.frame(sort_threee)
  TrigramData &lt;- sqldf("select tritoken,Freq from sort_threee");
  Most_Frequent &lt;- subset(TrigramData,TrigramData$Freq&gt;=2)
  write.csv(TrigramData, file = "D:\\TextAnalysisPOC_MasterPet\\Analysis.csv")
  </code></pre>
  
  <p><strong>Actual Output:</strong></p>
  
  <pre><code>    +---------------------------+-------------+
      |          Terms            |  Frequency  |        
      +---------------------------+-------------+
      |need address1 filed        |     1       |
      |mandatory leads display    |     1       |
      |record opportunities saved |     1       |
      |search list organization   |     1       |
      |activity resources display |     1       |
      +---------------------------+-------------+
  </code></pre>
  
  <p>Expected output:</p>
  
  <pre><code>   +-------------------------------+-------------+
      |          Terms               |  Frequency  |        
      +------------------------------+-------------+
      |need address1 field           |     1       |
      |address1 field mandatory      |     1       |
      |field mandatory leads         |     1       |
      |display record opportunities  |     1       |
      |record opportunities saved    |     1       |
      |opportunities saved search    |     1       |
      |saved search list             |     1       |
      |...................           |  ......     |
      +------------------------------+-------------+
  </code></pre>
  
  <p>Please help me achieve this expected output.
  I have data-set around 500+ records.</p>