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()
.
Arguments
- x
An object of class
tokens
.- file
Name of the output file.
- ...
Additional arguments (not implemented).
See also
Other writing functions:
write_assoc()
,
write_conc()
,
write_fnames()
,
write_freqlist()
,
write_txt()
,
write_types()
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)