Amazon Comprehend
Developer Guide

DetectEntities

Inspects text for named entities, and returns information about them. For more information, about named entities, see Detect Entities.

Request Syntax

{ "LanguageCode": "string", "Text": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

LanguageCode

The language of the input documents. You can specify English ("en") or Spanish ("es"). All documents must be in the same language.

Type: String

Valid Values: en | es

Required: Yes

Text

A UTF-8 text string. Each string must contain fewer that 5,000 bytes of UTF-8 encoded characters.

Type: String

Length Constraints: Minimum length of 1.

Required: Yes

Response Syntax

{ "Entities": [ { "BeginOffset": number, "EndOffset": number, "Score": number, "Text": "string", "Type": "string" } ] }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

Entities

A collection of entities identified in the input text. For each entity, the response provides the entity text, entity type, where the entity text begins and ends, and the level of confidence that Amazon Comprehend has in the detection. For a list of entity types, see Detect Entities.

Type: Array of Entity objects

Errors

For information about the errors that are common to all actions, see Common Errors.

InternalServerException

An internal server error occurred. Retry your request.

HTTP Status Code: 500

InvalidRequestException

The request is invalid.

HTTP Status Code: 400

TextSizeLimitExceededException

The size of the input text exceeds the limit. Use a smaller document.

HTTP Status Code: 400

UnsupportedLanguageException

Amazon Comprehend can't process the language of the input text. For all custom entity recognition APIs (such as CreateEntityRecognizer), only English is accepted. For most other APIs, Amazon Comprehend accepts only English or Spanish text.

HTTP Status Code: 400

Example

Detect entities

If the input text is "Bob ordered two sandwiches and three ice cream cones today from a store in Seattle.", the operation returns the following:

{ "Entities": [ { "Text": "Bob", "Score": 1.0, "Type": "PERSON", "BeginOffset": 0, "EndOffset": 3 }, { "Text": "two", "Score": 1.0, "Type": "QUANTITY", "BeginOffset": 12, "EndOffset": 15 }, { "Text": "three", "Score": 1.0, "Type": "QUANTITY", "BeginOffset": 32, "EndOffset": 37 }, { "Text": "Today", "Score": 1.0, "Type": "DATE", "BeginOffset": 54, "EndOffset": 59 }, { "Text": "Seattle", "Score": 1.0, "Type": "LOCATION", "BeginOffset": 76, "EndOffset": 83 } ], }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: