R R.package !!!ngram {{pre install.packages("ngram") library(ngram) > sample <- "I often hear that death penalty is reasonable for people whose family member or friend is killed by someone." > get.ngrams(ngram(sample)) [1] "death penalty" "is reasonable" "hear that" "friend is" "is killed" "for people" "whose family" [8] "by someone." "often hear" "people whose" "that death" "killed by" "I often" "member or" [15] "or friend" "family member" "reasonable for" "penalty is" > > get.ngrams(ngram(preprocess(sample, remove.punct=TRUE))) [1] "death penalty" "is reasonable" "hear that" "friend is" "is killed" "i often" "for people" [8] "whose family" "often hear" "people whose" "by someone" "that death" "killed by" "member or" [15] "or friend" "family member" "reasonable for" "penalty is" > print(ngram(preprocess(sample, remove.punct=TRUE)), output="full") death penalty | 1 is {1} | is reasonable | 1 for {1} | hear that | 1 death {1} | friend is | 1 killed {1} | is killed | 1 by {1} | i often | 1 hear {1} | for people | 1 whose {1} | whose family | 1 member {1} | often hear | 1 that {1} | people whose | 1 family {1} | by someone | 1 NULL {1} | that death | 1 penalty {1} | killed by | 1 someone {1} | member or | 1 friend {1} | or friend | 1 is {1} | family member | 1 or {1} | reasonable for | 1 people {1} | penalty is | 1 reasonable {1} |