Learn R Programming

biogram (version 1.6.3)

add_1grams: Add 1-grams

Description

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

Usage

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.

Value

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

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.

See Also

Reverse function: gap_ngrams.

Examples

Run this code
# NOT RUN {
add_1grams("1_2.3.4_3.0", 1L:4, 8)

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

Run the code above in your browser using DataLab