Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
fix #16 make similarity defunct
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Nov 19, 2020
1 parent 34b08cc commit 4d6d85f
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 116 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Expand Up @@ -6,7 +6,7 @@ Description: The 'Microsoft Academic Knowledge' API provides programmatic access
(<https://academic.microsoft.com/>). Includes methods matching all 'Microsoft
Academic' API routes, including search, graph search, text similarity, and
interpret natural language query string.
Version: 0.5.0.91
Version: 0.5.2.91
Authors@R: c(
person("Scott", "Chamberlain", email = "myrmecocystus+r@gmail.com",
role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1444-9135")),
Expand All @@ -19,7 +19,7 @@ LazyData: TRUE
Encoding: UTF-8
Language: en-US
URL: https://github.com/ropensci/microdemic (devel),
https://docs.ropensci.org/microdemic (website)
https://docs.ropensci.org/microdemic/ (website)
BugReports: https://github.com/ropensci/microdemic/issues
Roxygen: list(markdown = TRUE)
Imports:
Expand Down
7 changes: 3 additions & 4 deletions R/microdemic-package.R
@@ -1,5 +1,5 @@
#' Microsoft Academic Client
#'
#' @title microdemic
#' @description Microsoft Academic Client
#' @section Links:
#'
#' * web interface: https://academic.microsoft.com/
Expand All @@ -13,7 +13,6 @@
#' * [ma_calchist()]
#' * [ma_evaluate()]
#' * [ma_interpret()]
#' * [ma_similarity()]
#' * [ma_abstract()]
#' * [ma_graph_search()]
#'
Expand Down Expand Up @@ -50,6 +49,6 @@
#' @name microdemic-package
#' @aliases microdemic
#' @docType package
#' @author Scott Chamberlain \email{myrmecocystus@@gmail.com}
#' @author Scott Chamberlain
#' @keywords package
NULL
50 changes: 6 additions & 44 deletions R/similarity.R
@@ -1,47 +1,9 @@
#' Similarity API
#'
#' DEFUNCT
#'
#' @export
#' @param s1,s2 (character) strings 1 and 2. required
#' @param method (character) one of GET (default) or POST
#' @param model (character) Name of the model that you wish to query. One of
#' 'latest' or 'beta-2015'. Default: latest
#' @param key (character) microsoft academic API key, see the `Authentication`
#' section in [microdemic-package]
#' @param ... curl options passed on to [crul::HttpClient]
#' @return a single value representing the cosine similarity of the text inputs
#' of s1 and s2. The output is represented by a floating point between -1.0
#' and +1.0. The similarity API evaluates the strings base on their academic
#' concepts, with +1.0 being the most similar and -1.0 being the least similar.
#' @examples \dontrun{
#' s1 <- "Using complementary priors, we derive a fast greedy algorithm that
#' can learn deep directed belief networks one layer at a time, provided the
#' top two layers form an undirected associative memory"
#'
#' s2 <- "Deepneural nets with a large number of parameters are very powerful
#' machine learning systems. However, overfitting is a serious problem in
#' such networks"
#'
#' ma_similarity(s1, s2)
#'
#' ma_similarity(s1, s2, method = "POST")
#' }
ma_similarity <- function(s1, s2, method = "GET", model = "latest",
key = NULL, ...) {

if (!method %in% c("GET", "POST")) stop("'method' must be one of GET or POST")

# assert(model, "character")
# if (!model %in% c('latest', 'beta-2015')) {
# stop("model must be one or 'latest' or 'beta-2015'")
# }

if (method == "GET") {
args <- comp(list(s1 = s1, s2 = s2, model = model))
ma_HTTP("academic/v1.0/similarity", args, key, ...)
} else {
args <- comp(list(model = model))
body <- sprintf("s1=%s&s2=%s", s1, s2)
ma_HTTP("academic/v1.0/similarity", NULL, key = key,
method = 'POST', args = args, body = body, ...)
}
}
#' @keywords internal
#' @rdname ma_similarity-defunct
#' @param ... ignored
ma_similarity <- function(...) .Defunct()
15 changes: 15 additions & 0 deletions man/ma_similarity-defunct.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 0 additions & 45 deletions man/ma_similarity.Rd

This file was deleted.

8 changes: 5 additions & 3 deletions man/microdemic-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions tests/testthat/test-similarity.R

This file was deleted.

0 comments on commit 4d6d85f

Please sign in to comment.