word_context: Word-context conditional expression

word_contextR Documentation

Word-context conditional expression

Description

Create word-context conditional expression with the ⁠%|%⁠ operator.

Usage

word %|% context

Arguments

word

a character vector. Word or words to include as the variable part of the conditional expression.

context

a character vector of length one. The fixed (or "given") part of the conditional expression.

Details

The intuitive meaning of the operator ⁠%|%⁠ is that of the mathematical symbol | (given). This operator is used to create conditional expressions representing the occurrence of some word after a given context (for instance, the expression "you" %|% "i love" would represent the occurrence of the word "you" after the string "i love"). The purpose of ⁠%|%⁠ is to create objects which can be given as input to probability() (see probability for further examples).

Value

a word_context class object.

Author(s)

Valerio Gherardi

Examples

f <- kgram_freqs(much_ado, 2, .tknz_sent = tknz_sent)
m <- language_model(f, "kn", D = 0.5)
probability("leonato" %|% "enter", m)


vgherard/kgrams documentation built on Nov. 17, 2024, 8:56 p.m.