add_1grams: Add 1-grams

Description Usage Arguments Details Value See Also Examples

View source: R/add_remove_ngrams.R

Description

Builds (n+1)-grams from n-grams.

Usage

1
add_1grams(ngram, u, seq_length)

Arguments

ngram

a single n-gram.

u

integer, numeric or character vector of all possible unigrams.

seq_length

length of an origin sequence.

Details

n-grams are built by pasting every possible unigram in the every possible free position. The total length of n-gram (n plus total distance between elements of the n-gram) is limited by the length of an origin sequence, because the n-gram cannot be longer than an origin sequence.

Value

vector of n-grams (where n is equal to the n of the input plus one).

See Also

Reverse function: gap_ngrams.

Examples

1
2
3
add_1grams("1_2.3.4_3.0", 1L:4, 8)

add_1grams("a.a_1", c("a", "b", "c"), 4)

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