R/tokens_restore.R

Defines functions tokens_restore

Documented in tokens_restore

#' Restore special tokens
#'
#' Compounds segments of tokens marked by special markers. The beginning and
#' the end of the segments should be marked by U+E001 and U+E002 respectively.
#' @param x tokens object
#' @returns a modified tokens object
#' @keywords internal tokens
tokens_restore <- function(x) {
    type <- types(x)
    attrs <- attributes(x)
    result <- qatd_cpp_tokens_restore(x, 
                                      list(match("\uE001", type)), 
                                      list(match("\uE002", type)), 
                                      type, "")
    rebuild_tokens(result, attrs)
}

Try the quanteda package in your browser

Any scripts or data that you put into this service are public.

quanteda documentation built on May 31, 2023, 8:28 p.m.