term_context: Terms in Context

View source: R/term_context.R

term_contextR Documentation

Terms in Context

Description

Shamelessly borrowing the quanteda::kwic() function (https://quanteda.io/index.html) for keyword search

Usage

term_context(
  data,
  pattern,
  window = 5,
  valuetype = c("glob", "regex", "fixed")
)

Arguments

data

Data frame created by GSPtext::get_reviews() or in the same format

pattern

Keyword or phrase to search for (See examples)

window

Number of words to display on either side of the keyword match

valuetype

Type of pattern match. "glob" for glob-style wildcards, "regex" for regular expressions, "fixed" for exact matching

Value

quanteda object with 7 variables (docname or index, from, to, pre, keyword, post, pattern)

Examples

## Not run: 
# single token
term_context(data, pattern = "quality", window = 4, valuetype = "glob")
term_context(data, pattern = "qual", valuetype = "regex", window = 4)

# phrase matching
term_context(data, pattern = "cheap quality", window = 4)

## End(Not run)

taylorgrant/GSPtext documentation built on April 15, 2023, 10:56 p.m.