Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to turn off the interactive question when running available() #53

Open
ColinFay opened this issue Jul 5, 2019 · 2 comments
Open
Labels
feature a feature request or enhancement

Comments

@ColinFay
Copy link

ColinFay commented Jul 5, 2019

It would be great if we could turn off the check by get_urban_data() when we call available().

Something like :

get_urban_data <- function (name, warn_offensive = TRUE) {
    if (interactive() & warn_offensive) {
        cat("Urban Dictionary can contain potentially offensive results,\n  should they be included? [Y]es / [N]o:\n")
        result <- tryCatch(scan("", what = "character", quiet = TRUE, 
            nlines = 1), error = function(x) "N")
        if (!identical(toupper(result), "Y")) {
            return(NULL)
        }
    }
    term <- tryCatch(as.data.frame(udapi::get_term(name)), error = function(e) e)
    tags <- tryCatch(udapi::get_tags(name)$tags, error = function(e) e)
    structure(list(term, tags), class = "available_urban")
}

And then

available <- function (name, browse = getOption("available.browse", TRUE), warn_offensive = TRUE, ...) {
    res <- list(valid_package_name(name), available_on_cran(name, 
        ...), available_on_bioc(name, ...), available_on_github(name))
    terms <- name_to_search_terms(name)
    res <- c(res, unlist(recursive = FALSE, lapply(terms, function(term) {
        compact(list(get_bad_words(term), get_abbreviation(term), 
            get_wikipidia(term), get_wiktionary(term), get_urban_data(term, warn_offensive), 
            get_sentiment(term)))
    })))
    structure(res, class = "available_query", packagename = name, 
        browse = browse)
}
@jimhester
Copy link
Member

Yeah, sounds good, want to do a PR?

@ColinFay
Copy link
Author

Sure, I will do !

ColinFay added a commit to ColinFay/available that referenced this issue Oct 8, 2019
@jimhester jimhester added the feature a feature request or enhancement label Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants