R interface to Azure Cognitive Services REST API
Перейти к файлу
Hong Ooi 59a2c36969 bump to dev version 2021-01-13 06:33:13 +11:00
.github/workflows switch to Github Actions, change maintainer email 2020-10-15 02:23:32 +11:00
R Fix token authentication method (#3) 2020-10-15 04:46:14 +11:00
man Fix token authentication method (#3) 2020-10-15 04:46:14 +11:00
tests Fix token authentication method (#3) 2020-10-15 04:46:14 +11:00
vignettes url fixups 2020-10-15 05:07:05 +11:00
.Rbuildignore switch to Github Actions, change maintainer email 2020-10-15 02:23:32 +11:00
.gitignore add vignette 2019-09-24 21:46:19 +10:00
CODE_OF_CONDUCT.md Initial commit 2019-09-20 19:17:15 -07:00
CONTRIBUTING.md more doc 2019-09-23 15:55:06 +10:00
DESCRIPTION bump to dev version 2021-01-13 06:33:13 +11:00
LICENSE init from AzureVision 2019-09-21 12:25:52 +10:00
LICENSE.md init from AzureVision 2019-09-21 12:25:52 +10:00
NAMESPACE make call_cognitive_endpoint a generic 2019-09-30 16:03:22 +10:00
NEWS.md bump version no for release 2020-10-15 05:32:12 +11:00
README.md url fixups 2020-10-15 05:07:05 +11:00
SECURITY.md Initial commit 2019-09-20 19:17:17 -07:00

README.md

AzureCognitive

CRAN Downloads R-CMD-check

A package to work with Azure Cognitive Services. Both a Resource Manager interface and a client interface to the REST API are provided.

The primary repo for this package is at https://github.com/Azure/AzureCognitive; please submit issues and PRs there. It is also mirrored at the Cloudyr org at https://github.com/cloudyr/AzureCognitive. You can install the development version of the package with devtools::install_github("Azure/AzureCognitive").

Resource Manager interface

AzureCognitive extends the class framework provided by AzureRMR to support Cognitive Services. You can create, retrieve, update, and delete cognitive service resources by calling the corresponding methods for a resource group.

az <- AzureRMR::get_azure_login()
sub <- az$get_subscription("sub_id")
rg <- sub$get_resource_group("rgname")

# create a new Computer Vision service
rg$create_cognitive_service("myvisionservice",
    service_type="ComputerVision", service_tier="S1")

# retrieve it
cogsvc <- rg$get_cognitive_service("myvisionservice")

# list subscription keys
cogsvc$list_keys()

Client interface

AzureCognitive implements basic functionality for communicating with a cognitive service endpoint. While it can be called by the end-user, it is meant to provide a foundation for other packages that will support specific services, like Computer Vision, LUIS (language understanding), etc.

# getting the endpoint from the resource object
endp <- cogsvc$get_endpoint()

# or standalone (must provide subscription key or other means of authentication)
endp <- cognitive_endpoint("https://myvisionservice.cognitiveservices.azure.com/",
    service_type="ComputerVision", key="key")

# analyze an image
img_link <- "https://news.microsoft.com/uploads/2014/09/billg1_print.jpg"
call_cognitive_endpoint(endp,
    operation="analyze",
    body=list(url=img_link),
    options=list(details="celebrities"),
    http_verb="POST")
$categories
$categories[[1]]
$categories[[1]]$name
[1] "people_"

$categories[[1]]$score
[1] 0.953125

$categories[[1]]$detail
$categories[[1]]$detail$celebrities
$categories[[1]]$detail$celebrities[[1]]
$categories[[1]]$detail$celebrities[[1]]$name
[1] "Bill Gates"

$categories[[1]]$detail$celebrities[[1]]$confidence
[1] 0.9999552