ngram_collocations: Ngram Collocations

Description Usage Arguments Value See Also Examples

View source: R/DEPRECATED.R

Description

Find a important ngram (2-3) collocations. Wraps collocations to provide stopword, min/max characters, and stemming with a generic plot function.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
ngram_collocations(
  text.var,
  n = 20,
  gram.length = 2:3,
  stopwords = stopwords::stopwords("english"),
  min.char = 4,
  max.char = Inf,
  order.by = "frequency",
  stem = FALSE,
  language = "porter",
  ...
)

Arguments

text.var

A vector of character strings.

n

The number of rows to include.

gram.length

The length of ngram to generate (2-3).

stopwords

A vector of stopwords to exclude.

min.char

The minimum number of characters a word must be (including apostrophes) for inclusion.

max.char

The maximum number of characters a word must be (including apostrophes) for inclusion.

order.by

The name of the measure column to order by: "frequency", "G2", "X2", "pmi", "dice".

stem

logical. If TRUE the wordStem is used with language = "porter" as the default. Note that stopwords will be stemmed as well.

language

The stem language to use (see wordStem).

...

Other arguments passed to collocations.

Value

Retuns a data.frame of terms and frequencies.

See Also

collocations

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
x <- presidential_debates_2012[["dialogue"]]

ngram_collocations(x)
ngram_collocations(x, n = 50)
ngram_collocations(x, stopwords = c(stopwords::stopwords("english"), "american", "governor"))
ngram_collocations(x, gram.length = 3)
ngram_collocations(x, gram.length = 3, stem = TRUE)
ngram_collocations(x, order.by = "lambda")

plot(ngram_collocations(x))
plot(ngram_collocations(x, n = 40))
plot(ngram_collocations(x, order.by = "lambda"))
plot(ngram_collocations(x, gram.length = 3))

## End(Not run)

trinker/termco documentation built on Jan. 7, 2022, 3:32 a.m.