DetectEntities - Amazon Comprehend

DetectEntities

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

Request Syntax

{ "EndpointArn": "string", "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.

EndpointArn

The Amazon Resource Name of an endpoint that is associated with a custom entity recognition model. Provide an endpoint if you want to detect entities by using your own custom model instead of the default model that is used by Amazon Comprehend.

If you specify an endpoint, Amazon Comprehend uses the language of your custom model, and it ignores any language code that you provide in your request.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:aws(-[^:]+)?:comprehend:[a-zA-Z0-9-]*:[0-9]{12}:entity-recognizer-endpoint/[a-zA-Z0-9](-*[a-zA-Z0-9])*

Required: No

LanguageCode

The language of the input documents. You can specify any of the primary languages supported by Amazon Comprehend. All documents must be in the same language.

If your request includes the endpoint for a custom entity recognition model, Amazon Comprehend uses the language of your custom model, and it ignores any language code that you specify here.

Type: String

Valid Values: en | es | fr | de | it | pt | ar | hi | ja | ko | zh | zh-TW

Required: No

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.

If your request uses a custom entity recognition model, Amazon Comprehend detects the entities that the model is trained to recognize. Otherwise, it detects the default entity types. For a list of default 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

ResourceUnavailableException

The specified resource is not available. Check the resource and try your request again.

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, Spanish, French, Italian, German, or Portuguese are accepted. For most other APIs, such as those for Custom Classification, Amazon Comprehend accepts text in all supported languages. For a list of supported languages, see Languages Supported in Amazon Comprehend.

HTTP Status Code: 400

Examples

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: