Description Usage Arguments Value Note Examples
View source: R/read_term_list.R
read_term_list
- Read-in and format a term list from an external file.
read_term_list
collapses the terms within categories by default. To
negate this behavior use source_term_list
.
write_term_list
- Write-out a term list to a file.
1 2 3 4 5 | read_term_list(path = "models/categories.R", indices = NULL, term.list, ...)
source_term_list(path = "models/categories.R", indices = NULL, ...)
write_term_list(term.list, path = "models/categories.R", ...)
|
path |
Path to external term list. |
indices |
Indices of the elements to retain (used to take part of a term list). |
term.list |
A term list object that can be passed rather than an external file. |
... |
ignored. |
Returns a formatted term list.
Note that for token_count
lists the default is to collapse the
elements of vectors into a single regex. This is undesired behavior when
dealing with fixed tokens. To avoid this behavior use the argument
collapse = FALSE
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | good_cats <- system.file("termco_docs/categories.R", package = "termco")
bad_cats <- system.file("termco_docs/mal_categories.R", package = "termco")
read_term_list(good_cats)
source_term_list(good_cats)
## Not run:
## Throws warnings
read_term_list(bad_cats)
## Using term list object
my_term_list <- list(
## Tier 1
list(
Response_Cries = c("\\boh", "\\bah", "\\baha", "\\bouch", "yuk"),
Back_Channels = c("uh[- ]huh", "uhuh", "yeah"),
Summons = "hey",
Justification = "because"
),
## Tier 2
list(
Summons = 'the',
Back_Channels = c('\\ber+\\b', 'hm+'),
Empty = c('^\\s*$')
),
## Tier 3
list(
Summons = c(),
Back_Channels = c()
),
## Tier 4
list(
Summons = 'hey you',
Justification = 'ed\\s',
Exclamation = c('\\!$', '^[^w]{0,5}wow+.{0,4}'),
Empty = c()
)
)
read_term_list(term.list = my_term_list)
## End(Not run)
discoure_markers <- list(
response_cries = c("\\boh", "\\bah", "\\baha", "\\bouch", "yuk"),
back_channels = c("uh[- ]huh", "uhuh", "yeah"),
summons = "hey",
justification = "because"
)
## writing to the console (not that useful)
write_term_list(discoure_markers, path = '')
trpl_list <- list(
list(
response_cries = c("\\boh", "\\bah", "\\baha", "\\bouch", "yuk"),
back_channels = c("uh[- ]huh", "uhuh", "yeah"),
summons = "hey",
justification = "because"
),
list(summons ='the'),
list(summons = 'it', justification = 'ed\\s')
)
## writing to the console (not that useful)
write_term_list(trpl_list, path = '')
## Writing to an external file
temp <- tempdir()
write_term_list(discoure_markers, path = file.path(temp, 'categories.R'))
read_term_list(path = file.path(temp, 'categories.R'))
source_term_list(path = file.path(temp, 'categories.R'))
write_term_list(trpl_list, path = file.path(temp, 'categories2.R'))
read_term_list(path = file.path(temp, 'categories2.R'))
source_term_list(path = file.path(temp, 'categories2.R'))
## Writing term list for non-R .json others to use:
## Not run:
my_term_list %>%
jsonlite::toJSON(pretty=TRUE) %>%
stringi::stri_unescape_unicode() %>%
cat(file = 'testing.json')
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.