Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

tCorpus-cash-context

Get a context vector


Description

Depending on the purpose, the context of an analysis can be the document level or sentence level. the tCorpus$context() method offers a convenient way to get the context id of tokens for different settings.

Arguments

context_level

Select whether the context is document or sentence level

with_labels

Return context as only ids (numeric, starting at 1) or with labels (factor)

Details

Usage:

## R6 method for class tCorpus. Use as tc$method (where tc is a tCorpus object).

data(context_level = c('document','sentence'), with_labels = T)

Examples

tc <- create_tcorpus(c('Text one first sentence. Text one second sentence', 'Text two'),
                     split_sentences = TRUE)

doc <- tc$context() ## default context is doc_id (document level)
doc

sent <- tc$context('sentence') ## can specify sentence level
sent

corpustools

Managing, Querying and Analyzing Tokenized Text

v0.4.10
GPL-3
Authors
Kasper Welbers and Wouter van Atteveldt
Initial release
2022-05-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.