collocations(x, ...)## S3 method for class 'character':
collocations(x, method = c("lr", "chi2", "pmi", "dice",
"all"), size = 2, n = NULL, ...)
## S3 method for class 'corpus':
collocations(x, method = c("lr", "chi2", "pmi", "dice",
"all"), size = 2, n = NULL, ...)
tokenize
. If wanted
to include collocations separated by punctuation, then you can use this to
send removePunct = TRUE
to
n=2
) and trigram
(n=3
) collocations are implemented so far. Can be c(2,3)
(or
2:3
) to return both bi- and tri-gram collocations.collocations
currently converts all text to ASCII prior to
processing. We hope to improve on this in the future.txt <- c("This is software testing: looking for (word) pairs!
This [is] a software testing again. For.",
"Here: this is more Software Testing, looking again for word pairs.")
collocations(txt)
collocations(txt, removePunct = TRUE)
collocations(txt, size=2:3)
removeFeatures(collocations(txt, size=2:3), stopwords("english"))
collocations("@textasdata We really, really love the #quanteda package - thanks!!")
collocations("@textasdata We really, really love the #quanteda package - thanks!!",
removeTwitter = TRUE)
collocations(inaugTexts[49:57], n=10)
collocations(inaugTexts[49:57], method="all", n=10)
collocations(inaugTexts[49:57], method="chi2", size=3, n=10)
collocations(subset(inaugCorpus, Year>1980), method="pmi", size=3, n=10)
Run the code above in your browser using DataLab