Description Usage Arguments Details Value References See Also Examples
The function send batch request (100 IDs per request) to microsoft sentiment analysis API and get a sentiment score between 0 to 1 for each textual data point. Each document/sentence size should not exceed 5,120 character.
1 | get_batch_sentiment(data, auth_key, api_region, batch_size)
|
data |
dataframe with 2 columns - 'text' and 'language' - is necessary to get sentiment score. Other columns will be maintained as is in the returned dataframe. Check Microsoft API website for more information on language options available. |
auth_key |
Authorization key associated with Microsoft API |
api_region |
Provide region for which the authorization key is valid. |
batch_size |
Default batch size is 100 considering free API trial. Change accordingly based on your paid subscription. |
The API wrapper uses the Microsoft Cognitive Services - Text Analytics API. The API uses Sentiment Analysis - v2.1 version. API generates sentiment score between 0 and 1 with scores closer to 1 indicate positive sentiment and score close to 0 indicate negative sentiment.
|
Function returns dataframe with additional 'Id' and 'Sentiment Score' columns for input data. |
Microsoft Sentiment Analysis Website
1 2 3 4 5 6 7 8 9 10 | require(httr)
require(jsonlite)
sent_data <- c('It was a beautiful day', 'I do not like this game')
sent_lang <- c('en', 'en')
dataset <- data.frame('text'=sent_data, 'language'=sent_lang)
# auth_key is your unique API access key and has region associated with it
#sentiment_data <- get_batch_sentiment(dataset, "eda0526b71ff44b29c", "westcentralus")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.