gap_ngrams: Gap n-grams

Description Usage Arguments Details Value See Also Examples

View source: R/add_remove_ngrams.R

Description

Introduces gaps in the n-grams.

Usage

1
gap_ngrams(ngrams)

Arguments

ngrams

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

Details

A single element of the input n-gram at a time will be replaced by a gap. For example, introducing gaps in n-gram 2_1.1.2_0.1 will results in three n-grams: 3_1.2_1 (where the 2_1_0 unigram was replaced by a gap), 2_1.2_2 and 2_1.1_0.

Value

A character vector of (n-1)-grams with introduced gaps.

See Also

Reverse function: add_1grams.

Examples

1
2
gap_ngrams(c("2_1.1.2_0.1", "3_1.1.2_0.0", "3_2.2.2_0.0"))
gap_ngrams(c("1.1.2_0.1", "1.1.2_0.0", "2.2.2_0.0"))

Example output

Loading required package: slam
[1] "3_1.2_1" "2_1.2_2" "2_1.1_0" "4_1.2_0" "3_1.1_0" "4_2.2_0" "3_2.2_1"
[8] "3_2.2_0"
[1] "1.2_1" "1.2_2" "1.1_0" "1.2_0" "2.2_0" "2.2_1"

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