tokens2sequences_conform: Match the feature names of one tokens2sequences object to...

View source: R/tokens2sequences.R

tokens2sequences_conformR Documentation

Match the feature names of one tokens2sequences object to another

Description

Converts the feature names of one tokens2sequences object to those of another. Useful in aligning training and test sets.

Usage

tokens2sequences_conform(x, y)

Arguments

x

tokens2sequences() object that will be forced to conform

y

tokens2sequences() object whose feature names will be used to change token labels for x

See Also

tokens2sequences()

Examples

## Not run: 
corpcoded <- corpus_subset(data_corpus_manifestosentsUK, !is.na(crowd_immigration_label))
corpuncoded <- data_corpus_manifestosentsUK %>%
    corpus_subset(is.na(crowd_immigration_label) & year > 1980) %>%
    corpus_sample(size = ndoc(corpcoded))

tokx <- tokens(corpuncoded)
toky <- tokens(corpcoded)

seqx <- tokens2sequences(tokx, maxsenlen = 50, keepn = 5000)
seqy <- tokens2sequences(toky, maxsenlen = 50, keepn = 5000)
tokens2sequences_conform(seqx, seqy)

## End(Not run)

quanteda/quanteda.classifiers documentation built on Oct. 20, 2023, 6:53 a.m.