Microsoft Cognitive Language Service - 2022-05-15-preview
The language service API is a suite of natural language processing (NLP) skills built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction, language detection and question answering. Further documentation can be found in https://docs.microsoft.com/en-us/azure/cognitive-services/language-service/overview.0
Get analysis status and results
Get the status of an analysis job. A job may consist of one or more tasks. Once all tasks are succeeded, the job will transition to the succeeded state and results will be available for each task.
Select the testing console in the region where you created your resource:
Open API testing consoleRequest URL
Request parameters
Format - uuid. Job ID
(Optional) if set to true, response will contain request and document level statistics.
Format - int32. The maximum number of resources to return from the collection.
Format - int32. An offset into the collection of the first resource to be returned.
Request headers
Request body
Response 200
Analysis job status and metadata.
{
"jobId": "bd282c47-3d9d-4458-952e-0e8c81e6d4ed",
"lastUpdatedDateTime": "2022-05-23T15:02:20Z",
"createdDateTime": "2022-05-23T15:02:03Z",
"expirationDateTime": "2022-05-24T15:02:03Z",
"status": "succeeded",
"errors": [],
"displayName": "Extracting Location & US Region",
"tasks": {
"completed": 6,
"failed": 0,
"inProgress": 0,
"total": 6,
"items": [
{
"kind": "HealthcareLROResults",
"taskName": "Health care",
"lastUpdateDateTime": "2022-05-23T15:02:04.6793817Z",
"status": "succeeded",
"results": {
"documents": [
{
"id": "1",
"entities": [
{
"offset": 34,
"length": 9,
"text": "last week",
"category": "Time",
"confidenceScore": 0.89
}
],
"relations": [],
"warnings": []
},
{
"id": "2",
"entities": [
{
"offset": 18,
"length": 8,
"text": "tomorrow",
"category": "Time",
"confidenceScore": 0.96
}
],
"relations": [],
"warnings": []
}
],
"errors": [],
"modelVersion": "2022-03-01"
}
},
{
"kind": "EntityLinkingLROResults",
"taskName": "Linking Entities",
"lastUpdateDateTime": "2022-05-23T15:02:05.9168608Z",
"status": "succeeded",
"results": {
"documents": [
{
"id": "1",
"entities": [
{
"bingId": "5fbba6b8-85e1-4d41-9444-d9055436e473",
"name": "Seattle",
"matches": [
{
"text": "Seattle",
"offset": 26,
"length": 7,
"confidenceScore": 0.19
}
],
"language": "en",
"id": "Seattle",
"url": "https://en.wikipedia.org/wiki/Seattle",
"dataSource": "Wikipedia"
}
],
"warnings": []
},
{
"id": "2",
"entities": [
{
"bingId": "60d5dc2b-c915-460b-b722-c9e3485499ca",
"name": "New York City",
"matches": [
{
"text": "NYC",
"offset": 14,
"length": 3,
"confidenceScore": 0.05
}
],
"language": "en",
"id": "New York City",
"url": "https://en.wikipedia.org/wiki/New_York_City",
"dataSource": "Wikipedia"
},
{
"bingId": "ffc581d3-e16c-46a5-bfbb-3ea5fc9f4bfa",
"name": "See You There",
"matches": [
{
"text": "See you there",
"offset": 28,
"length": 13,
"confidenceScore": 0.64
}
],
"language": "en",
"id": "See You There",
"url": "https://en.wikipedia.org/wiki/See_You_There",
"dataSource": "Wikipedia"
}
],
"warnings": []
}
],
"errors": [],
"modelVersion": "2021-06-01"
}
},
{
"kind": "EntityRecognitionLROResults",
"taskName": "Recognize Entities",
"lastUpdateDateTime": "2022-05-23T15:02:06.0124294Z",
"status": "succeeded",
"results": {
"documents": [
{
"id": "1",
"entities": [
{
"text": "trip",
"category": "Event",
"offset": 18,
"length": 4,
"confidenceScore": 0.74
},
{
"text": "Seattle",
"category": "Location",
"subcategory": "GPE",
"offset": 26,
"length": 7,
"confidenceScore": 1.0
},
{
"text": "last week",
"category": "DateTime",
"subcategory": "DateRange",
"offset": 34,
"length": 9,
"confidenceScore": 0.8
}
],
"warnings": []
},
{
"id": "2",
"entities": [
{
"text": "NYC",
"category": "Location",
"subcategory": "GPE",
"offset": 14,
"length": 3,
"confidenceScore": 1.0
},
{
"text": "tomorrow",
"category": "DateTime",
"subcategory": "Date",
"offset": 18,
"length": 8,
"confidenceScore": 0.8
}
],
"warnings": []
}
],
"errors": [],
"modelVersion": "2021-06-01"
}
},
{
"kind": "KeyPhraseExtractionLROResults",
"taskName": "Extracting Key Phrase",
"lastUpdateDateTime": "2022-05-23T15:02:12.0007265Z",
"status": "succeeded",
"results": {
"documents": [
{
"id": "1",
"keyPhrases": [
"wonderful trip",
"Seattle"
],
"warnings": []
},
{
"id": "2",
"keyPhrases": [
"NYC"
],
"warnings": []
}
],
"errors": [],
"modelVersion": "2021-06-01"
}
},
{
"kind": "PiiEntityRecognitionLROResults",
"taskName": "Personal Entity Recognition",
"lastUpdateDateTime": "2022-05-23T15:02:20.3859847Z",
"status": "succeeded",
"results": {
"documents": [
{
"redactedText": "I had a wonderful trip to Seattle *********.",
"id": "1",
"entities": [
{
"text": "last week",
"category": "DateTime",
"subcategory": "DateRange",
"offset": 34,
"length": 9,
"confidenceScore": 0.8
}
],
"warnings": []
},
{
"redactedText": "I'm flying to NYC ********. See you there.",
"id": "2",
"entities": [
{
"text": "tomorrow",
"category": "DateTime",
"subcategory": "Date",
"offset": 18,
"length": 8,
"confidenceScore": 0.8
}
],
"warnings": []
}
],
"errors": [],
"modelVersion": "2021-01-15"
}
},
{
"kind": "SentimentAnalysisLROResults",
"taskName": "Anlyzing Document Sentiment",
"lastUpdateDateTime": "2022-05-23T15:02:12.2574379Z",
"status": "succeeded",
"results": {
"documents": [
{
"id": "1",
"sentiment": "positive",
"confidenceScores": {
"positive": 1.0,
"neutral": 0.0,
"negative": 0.0
},
"sentences": [
{
"sentiment": "positive",
"confidenceScores": {
"positive": 1.0,
"neutral": 0.0,
"negative": 0.0
},
"offset": 0,
"length": 44,
"text": "I had a wonderful trip to Seattle last week."
}
],
"warnings": []
},
{
"id": "2",
"sentiment": "neutral",
"confidenceScores": {
"positive": 0.04,
"neutral": 0.95,
"negative": 0.01
},
"sentences": [
{
"sentiment": "neutral",
"confidenceScores": {
"positive": 0.05,
"neutral": 0.94,
"negative": 0.01
},
"offset": 0,
"length": 27,
"text": "I'm flying to NYC tomorrow."
},
{
"sentiment": "neutral",
"confidenceScores": {
"positive": 0.03,
"neutral": 0.96,
"negative": 0.01
},
"offset": 28,
"length": 14,
"text": "See you there."
}
],
"warnings": []
}
],
"errors": [],
"modelVersion": "2020-04-01"
}
}
]
}
}
Response 500
Unexpected error
Code samples
@ECHO OFF
curl -v -X GET "https://*.cognitiveservices.azure.com/language/analyze-text/jobs/{jobId}?api-version=2022-05-15-preview?showStats={boolean}&top={integer}&skip={integer}"
-H "Ocp-Apim-Subscription-Key: {subscription key}"
--data-ascii "{body}"
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeRequest();
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
// Request headers
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");
// Request parameters
queryString["showStats"] = "{boolean}";
queryString["top"] = "{integer}";
queryString["skip"] = "{integer}";
var uri = "https://*.cognitiveservices.azure.com/language/analyze-text/jobs/{jobId}?api-version=2022-05-15-preview&" + queryString;
var response = await client.GetAsync(uri);
}
}
}
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample
{
public static void main(String[] args)
{
HttpClient httpclient = HttpClients.createDefault();
try
{
URIBuilder builder = new URIBuilder("https://*.cognitiveservices.azure.com/language/analyze-text/jobs/{jobId}?api-version=2022-05-15-preview");
builder.setParameter("showStats", "{boolean}");
builder.setParameter("top", "{integer}");
builder.setParameter("skip", "{integer}");
URI uri = builder.build();
HttpGet request = new HttpGet(uri);
request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");
// Request body
StringEntity reqEntity = new StringEntity("{body}");
request.setEntity(reqEntity);
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null)
{
System.out.println(EntityUtils.toString(entity));
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
var params = {
// Request parameters
"showStats": "{boolean}",
"top": "{integer}",
"skip": "{integer}",
};
$.ajax({
url: "https://*.cognitiveservices.azure.com/language/analyze-text/jobs/{jobId}?api-version=2022-05-15-preview&" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
},
type: "GET",
// Request body
data: "{body}",
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString* path = @"https://*.cognitiveservices.azure.com/language/analyze-text/jobs/{jobId}?api-version=2022-05-15-preview";
NSArray* array = @[
// Request parameters
@"entities=true",
@"showStats={boolean}",
@"top={integer}",
@"skip={integer}",
];
NSString* string = [array componentsJoinedByString:@"&"];
path = [path stringByAppendingFormat:@"?%@", string];
NSLog(@"%@", path);
NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
[_request setHTTPMethod:@"GET"];
// Request headers
[_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
// Request body
[_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse *response = nil;
NSError *error = nil;
NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
if (nil != error)
{
NSLog(@"Error: %@", error);
}
else
{
NSError* error = nil;
NSMutableDictionary* json = nil;
NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
NSLog(@"%@", dataString);
if (nil != _connectionData)
{
json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
}
if (error || !json)
{
NSLog(@"Could not parse loaded json with error:%@", error);
}
NSLog(@"%@", json);
_connectionData = nil;
}
[pool drain];
return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';
$request = new Http_Request2('https://*.cognitiveservices.azure.com/language/analyze-text/jobs/{jobId}?api-version=2022-05-15-preview');
$url = $request->getUrl();
$headers = array(
// Request headers
'Ocp-Apim-Subscription-Key' => '{subscription key}',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
'showStats' => '{boolean}',
'top' => '{integer}',
'skip' => '{integer}',
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_GET);
// Request body
$request->setBody("{body}");
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
headers = {
# Request headers
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.urlencode({
# Request parameters
'showStats': '{boolean}',
'top': '{integer}',
'skip': '{integer}',
})
try:
conn = httplib.HTTPSConnection('*.cognitiveservices.azure.com')
conn.request("GET", "/language/analyze-text/jobs/{jobId}?api-version=2022-05-15-preview&%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
# Request headers
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.parse.urlencode({
# Request parameters
'showStats': '{boolean}',
'top': '{integer}',
'skip': '{integer}',
})
try:
conn = http.client.HTTPSConnection('*.cognitiveservices.azure.com')
conn.request("GET", "/language/analyze-text/jobs/{jobId}?api-version=2022-05-15-preview&%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('https://*.cognitiveservices.azure.com/language/analyze-text/jobs/{jobId}?api-version=2022-05-15-preview')
query = URI.encode_www_form({
# Request parameters
'showStats' => '{boolean}',
'top' => '{integer}',
'skip' => '{integer}'
})
if query.length > 0
if uri.query && uri.query.length > 0
uri.query += '&' + query
else
uri.query = query
end
end
request = Net::HTTP::Get.new(uri.request_uri)
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request body
request.body = "{body}"
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request(request)
end
puts response.body