position_ngrams: Position n-grams

Description Usage Arguments Value See Also Examples

View source: R/position_ngrams.R

Description

Tranforms a vector of positioned n-grams into a list of positions filled with n-grams that start on them.

Usage

1
position_ngrams(ngrams, df = FALSE, unigrams_output = TRUE)

Arguments

ngrams

a vector of positioned n-grams (as created by count_ngrams).

df

logical, if TRUE returns a data frame, if FALSE returns a list.

unigrams_output

logical, if TRUE extracts unigrams from the data and returns information about their position.

Value

if df is FALSE, returns a list of length equal to the number of unique n-gram starts present in n-grams. Each element of the list contains n-grams that start on this position. If df is FALSE, returns a data frame where first column contains n-grams and the second column represent their start positions.

See Also

Transform n-gram name to human-friendly form: decode_ngrams.

Validate n-gram structure: is_ngram.

Examples

1
2
3
4
# position data in the list format
position_ngrams(c("2_1.1.2_0.1", "3_1.1.2_0.0", "3_2.2.2_0.0"))
# position data in the data frame format
position_ngrams(c("2_1.1.2_0.1", "3_1.1.2_0.0", "3_2.2.2_0.0"), df = TRUE)

biogram documentation built on March 31, 2020, 5:14 p.m.