detect_entities
¶
detect_entities(
*,
config_overrides: Optional[ComprehendClientConfig] = None,
text: Optional[CustomerInputString] = None,
language_code: Optional[LanguageCode] = None,
endpoint_arn: Optional[EntityRecognizerEndpointArn] = None,
bytes: Optional[SemiStructuredDocumentBlob] = None,
document_reader_config: Optional[DocumentReaderConfig] = None,
) -> DetectEntitiesResponse
Detects named entities in input text when you use the pre-trained model. Detects custom entities if you have a custom entity recognition model.
When detecting named entities using the pre-trained model, use plain text as the input. For more information about named entities, see Entities in the Comprehend Developer Guide.
When you use a custom entity recognition model, you can input plain text or you can upload a single-page input document (text, PDF, Word, or image).
If the system detects errors while processing a page in the input document, the API response includes an entry in Errors for each error.
If the system detects a document-level error in your input document, the API returns an InvalidRequestException error response. For details about this exception, see Errors in semi-structured documents in the Comprehend Developer Guide.
Parameters:
-
text(Optional[CustomerInputString], default:None) –A UTF-8 text string. The maximum string size is 100 KB. If you enter text using this parameter, do not use the
Bytesparameter. -
language_code(Optional[LanguageCode], default:None) –The language of the input documents. You can specify any of the primary languages supported by Amazon Comprehend. 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.
All input documents must be in the same language.
-
endpoint_arn(Optional[EntityRecognizerEndpointArn], default:None) –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.
For information about endpoints, see Managing endpoints.
-
bytes(Optional[SemiStructuredDocumentBlob], default:None) –This field applies only when you use a custom entity recognition model that was trained with PDF annotations. For other cases, enter your text input in the
Textfield.Use the
Bytesparameter to input a text, PDF, Word or image file. Using a plain-text file in theBytesparameter is equivelent to using theTextparameter (theEntitiesfield in the response is identical).You can also use the
Bytesparameter to input an Amazon TextractDetectDocumentTextorAnalyzeDocumentoutput file.Provide the input document as a sequence of base64-encoded bytes. If your code uses an Amazon Web Services SDK to detect entities, the SDK may encode the document file bytes for you.
The maximum length of this field depends on the input document type. For details, see Inputs for real-time custom analysis in the Comprehend Developer Guide.
If you use the
Bytesparameter, do not use theTextparameter. -
document_reader_config(Optional[DocumentReaderConfig], default:None) –Provides configuration parameters to override the default actions for extracting text from PDF documents and image files.
Raises:
-
InternalServerException–An internal server error occurred. Retry your request.
-
InvalidRequestException–The request is invalid.
-
ResourceUnavailableException–The specified resource is not available. Check the resource and try your request again.
-
TextSizeLimitExceededException–The size of the input text exceeds the limit. Use a smaller document.
-
UnsupportedLanguageException–Amazon Comprehend can't process the language of the input text. For a list of supported languages, Supported languages in the Comprehend Developer Guide.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_comprehend/_services/comprehend.py
2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 | |