Description Usage Arguments Value Examples
Convenience function to convert a data forms of terms into a named list. For vectors, names are the same as the terms.
1 | as_term_list(x, add.boundary = FALSE, collapse = FALSE, test.regex = TRUE, ...)
|
x |
A vector of strings or a quanteda |
add.boundary |
logical. If |
collapse |
logical. If |
test.regex |
logical. If |
... |
If |
Returns a named list.
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 | as_term_list(state.name)
## Not run:
if (!require("pacman")) install.packages("pacman")
pacman::p_load(tidyverse, textshape)
x <- presidential_debates_2012[["dialogue"]]
ngrams <- frequent_ngrams(x, n=10) %>%
transmute(ngram = collocation) %>%
unlist() %>%
as_term_list()
presidential_debates_2012 %>%
with(term_count(dialogue, person, ngrams))
## dictionary from quanteda
require(quanteda)
mfdict <- textreadr::download("https://provalisresearch.com/Download/LaverGarry.zip") %>%
unzip(exdir = tempdir()) %>%
`[`(1) %>%
dictionary(file = .)
as_term_list(mfdict)
as_term_list(mfdict, add.boundary = TRUE)
as_term_list(mfdict, sep = ' -> ')
as_term_list(mfdict) %>%
tidy_list('category', 'regex')
## End(Not run)
## Writing term list for non-R .json others to use:
## Not run:
as_term_list(mfdict, TRUE) %>%
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.