This repository has been archived by the owner on Sep 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
31 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = "[email protected]", | ||
role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1444-9135")), | ||
|
@@ -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: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.