Skip to content

Commit 53758e0

Browse files
committed
Adding ResourceDownloader functions
1 parent 7a63423 commit 53758e0

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

NAMESPACE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ export(nlp_chunk_filterer)
227227
export(nlp_chunker)
228228
export(nlp_classifier_dl)
229229
export(nlp_classifier_dl_pretrained)
230+
export(nlp_clear_cache)
230231
export(nlp_conll_read_dataset)
231232
export(nlp_conllu_read_dataset)
232233
export(nlp_context_spell_checker)
@@ -301,6 +302,9 @@ export(nlp_sentiment_dl_pretrained)
301302
export(nlp_set_input_cols)
302303
export(nlp_set_output_col)
303304
export(nlp_set_param)
305+
export(nlp_show_available_annotators)
306+
export(nlp_show_public_models)
307+
export(nlp_show_public_pipelines)
304308
export(nlp_spark_annotation)
305309
export(nlp_stemmer)
306310
export(nlp_stop_words_cleaner)

R/resource_downloader.R

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#' SparkNLP ResourceDownloader functions
2+
#'
3+
#' ResourceDownloader provides functions to easily look for pretrained models & pipelines
4+
#' inside Spark NLP. You can filter models or pipelines via language, version,
5+
#' or the name of the annotator
6+
#'
7+
#' @param sc a spark_connect object
8+
#' @param lang language to restrict the results to
9+
#' @param version Spark NLP version to restrict results to
10+
#'
11+
#' @return a markdown table containing the models or pipelines filtered by the provided arguments
12+
#'
13+
#' @name nlp_resource_downloader
14+
#' @aliases ResourceDownloader
15+
NULL
16+
17+
#' @rdname nlp_resource_downloader
18+
#' @export
19+
nlp_show_public_pipelines <- function(sc, lang = NULL, version = NULL) {
20+
result <- sparklyr::invoke_static(sc, "com.johnsnowlabs.nlp.pretrained.PythonResourceDownloader", "showPublicPipelines", lang, version)
21+
return(result)
22+
}
23+
24+
#' @param annotator name of annotator to restrict results
25+
#' @rdname nlp_resource_downloader
26+
#' @export
27+
nlp_show_public_models <- function(sc, annotator = NULL, lang = NULL, version = NULL) {
28+
result <- sparklyr::invoke_static(sc, "com.johnsnowlabs.nlp.pretrained.PythonResourceDownloader", "showPublicModels", annotator, lang, version)
29+
return(result)
30+
}
31+
32+
#' @param name name of object to clear
33+
#' @param language language to clear
34+
#' @param remote_loc remote_loc of models to clear
35+
#' @rdname nlp_resource_downloader
36+
#' @export
37+
nlp_clear_cache <- function(sc, name = NULL, language = NULL, remote_loc = NULL) {
38+
result <- sparklyr::invoke_static(sc, "com.johnsnowlabs.nlp.pretrained.PythonResourceDownloader", "clearCache", name, language, remote_loc)
39+
return(result)
40+
}
41+
42+
#' @rdname nlp_resource_downloader
43+
#' @export
44+
nlp_show_available_annotators <- function(sc) {
45+
result <- sparklyr::invoke_static(sc, "com.johnsnowlabs.nlp.pretrained.PythonResourceDownloader", "showAvailableAnnotators")
46+
return(result)
47+
}

man/nlp_resource_downloader.Rd

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)