Skip to contents

This function reads an object of the class tokens from a text file, typically stored with write_tokens(). The text file is assumed to contain one token on each line and not to have a header.

Usage

read_tokens(file, file_encoding = "UTF-8", ...)

Arguments

file

Name of the input file.

file_encoding

Encoding to read the input file.

...

Additional arguments (not implemented).

Value

An object of class tokens.

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)