Define which parts of a zip file should be converted via which functions.
Value
A specification of imports which is necessary for
jst_import_zip()
.
Details
The function accepts the following names: article, book, report, pamphlet, ngram1, ngram2, ngram3. The corresponding files from a .zip-archive will be imported via the supplied functions.
Examples
# articles will be imported via `jst_get_article()` and `jst_get_authors()`
jst_define_import(article = c(jst_get_article, jst_get_authors))
#> # A tibble: 1 × 4
#> meta_type fun_names evaled_funs bare_funs
#> <chr> <list> <named list> <quos>
#> 1 journal_article <chr [2]> <list [2]> c(jst_get_article, jst_get_authors)
# define a specification for importing article metadata and unigrams (ngram1)
jst_define_import(article = jst_get_article,
ngram1 = jst_get_ngram)
#> # A tibble: 2 × 4
#> meta_type fun_names evaled_funs bare_funs
#> <chr> <list> <named list> <quos>
#> 1 journal_article <chr [1]> <fn> jst_get_article
#> 2 ngram1 <chr [1]> <fn> jst_get_ngram
# import all four types with one function each
jst_define_import(article = jst_get_article,
book = jst_get_book,
report = jst_get_book,
pamphlet = jst_get_article)
#> # A tibble: 4 × 4
#> meta_type fun_names evaled_funs bare_funs
#> <chr> <list> <named list> <quos>
#> 1 journal_article <chr [1]> <fn> jst_get_article
#> 2 book_chapter <chr [1]> <fn> jst_get_book
#> 3 research_report <chr [1]> <fn> jst_get_book
#> 4 pamphlet <chr [1]> <fn> jst_get_article
# import all four types with multiple functions
jst_define_import(article = c(jst_get_article, jst_get_authors, jst_get_references),
book = c(jst_get_book, jst_get_chapters),
report = jst_get_book,
pamphlet = jst_get_article)
#> # A tibble: 4 × 4
#> meta_type fun_names evaled_funs bare_funs
#> <chr> <list> <named list> <quos>
#> 1 journal_article <chr [3]> <list [3]> c(jst_get_article, jst_get_authors, js…
#> 2 book_chapter <chr [2]> <list [2]> c(jst_get_book, jst_get_chapters) …
#> 3 research_report <chr [1]> <fn> jst_get_book …
#> 4 pamphlet <chr [1]> <fn> jst_get_article …
# if you want to import chapters with authors, you can use an anonymous
# function
chapters_w_authors <- function(x) jst_get_chapters(x, authors = TRUE)
jst_define_import(book = chapters_w_authors)
#> # A tibble: 1 × 4
#> meta_type fun_names evaled_funs bare_funs
#> <chr> <list> <named list> <quos>
#> 1 book_chapter <chr [1]> <fn> chapters_w_authors
if (FALSE) { # \dontrun{
# define imports
imports <- jst_define_import(article = c(jst_get_article, jst_get_authors))
# convert the files to .csv
jst_import_zip("my_archive.zip", out_file = "my_out_file",
import_spec = imports)
} # }