Skip to contents

This function writes an object of the class tokens to a text file. Each token is written to a separate line. The file encoding is always "UTF-8". This file can later be read with read_tokens().

Usage

write_tokens(x, file, ...)

Arguments

x

An object of class tokens.

file

Name of the output file.

...

Additional arguments (not implemented).

Value

Invisibly, x.

See also

Examples

.old_wd <- setwd(tempdir())
(tks <- tokenize("The old man and the sea."))
#> Token sequence of length 6
#> idx token
#> --- -----
#>   1   the
#>   2   old
#>   3   man
#>   4   and
#>   5   the
#>   6   sea
write_tokens(tks, "file_with_tokens.txt")
(tks2 <- read_tokens("file_with_tokens.txt"))
#> Token sequence of length 6
#> idx token
#> --- -----
#>   1   the
#>   2   old
#>   3   man
#>   4   and
#>   5   the
#>   6   sea
setwd(.old_wd)