I am writing an R script and using the library (ngram).
Suppose I have a string,
"good qualiti dog food buy segment vital dog food product found good quality product look like stew meat smell better Labrador finicki boost product better"
and want to find bigrams.
The ngram library gives me bigrams as follows:
"value the product", "meat", "food product", "purchased food", "quality dog", "product found", "type of product", "similar", "like stew" "good qualiti" "labrador finicki "" quality product "" best labrador " " dog food " " smells better "" vital "" meat smell "" found good "," separate the vital "" stewing process "," can the dog "" finicki appreci "" the product is better "
Since the sentence contains “dog food” two times, I want this two-gram two times. But I get it once!
Is there an option in thengram library or in any other library that gives all the bigrams of my sentence in R?
source share