read_lexicon: Read a backslash-coded lexicon file into a tibble

Description Usage Arguments Examples

Description

Read a backslash-coded lexicon file into a tibble

Usage

1
read_lexicon(file, col_names = c("line", "data"), remove = FALSE, ...)

Arguments

file

either a path to a file, a connection, or literal data

col_names

names for line number and data columns (defaults to "line" and "data")

remove

Whether tidyr::extract should remove the "data" column

...

Further arguments passed to tidyr::extract

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Demo: Two literal backslash-coded lexemes
read_lexicon("\\lx bonjour\n\\de hello\n\n\\lx au revoir\n\\de goodbye")

# Demo: Extract backslash code and line value from data
read_lexicon("\\lx bonjour\n\\de hello\n\n\\lx au revoir\n\\de goodbye",
             regex = "\\\\([a-z]+)\\s(.*)", into = c("code", "value"))

# More typical usage (where file path to a lexicon is known):
lexicon_file <- system.file("extdata", "mini-french.txt", package = "tidylex")
read_lexicon(file = lexicon_file, regex = "\\\\([a-z]+)\\s(.*)", into = c("code", "value"))

CoEDL/tidylex documentation built on May 7, 2019, 10:50 p.m.