

Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.

# Starten Sie die asynchrone Texterkennung mit Amazon Textract und einemAWSSDK
<a name="example_textract_StartDocumentTextDetection_section"></a>

Im folgenden Codebeispiel wird veranschaulicht, wie Sie die asynchrone Texterkennung in einem Dokument mit Amazon Textract starten.

------
#### [ Python ]

**SDK for Python (Boto3)**  
Starten Sie einen asynchronen Auftrag, um Text in einem Dokument zu erkennen.  

```
class TextractWrapper:
    """Encapsulates Textract functions."""
    def __init__(self, textract_client, s3_resource, sqs_resource):
        """
        :param textract_client: A Boto3 Textract client.
        :param s3_resource: A Boto3 Amazon S3 resource.
        :param sqs_resource: A Boto3 Amazon SQS resource.
        """
        self.textract_client = textract_client
        self.s3_resource = s3_resource
        self.sqs_resource = sqs_resource

    def start_detection_job(
            self, bucket_name, document_file_name, sns_topic_arn, sns_role_arn):
        """
        Starts an asynchronous job to detect text elements in an image stored in an
        Amazon S3 bucket. Textract publishes a notification to the specified Amazon SNS
        topic when the job completes.
        The image must be in PNG, JPG, or PDF format.

        :param bucket_name: The name of the Amazon S3 bucket that contains the image.
        :param document_file_name: The name of the document image stored in Amazon S3.
        :param sns_topic_arn: The Amazon Resource Name (ARN) of an Amazon SNS topic
                              where the job completion notification is published.
        :param sns_role_arn: The ARN of an AWS Identity and Access Management (IAM)
                             role that can be assumed by Textract and grants permission
                             to publish to the Amazon SNS topic.
        :return: The ID of the job.
        """
        try:
            response = self.textract_client.start_document_text_detection(
                DocumentLocation={
                    'S3Object': {'Bucket': bucket_name, 'Name': document_file_name}},
                NotificationChannel={
                    'SNSTopicArn': sns_topic_arn, 'RoleArn': sns_role_arn})
            job_id = response['JobId']
            logger.info(
                "Started text detection job %s on %s.", job_id, document_file_name)
        except ClientError:
            logger.exception("Couldn't detect text in %s.", document_file_name)
            raise
        else:
            return job_id
```
+  Weitere Anleitungen und mehr Code finden Sie im [GitHub](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/textract#code-examples). 
+  API-Details dazu finden Sie unter.[StartDocumentTextDetection](https://docs.aws.amazon.com/goto/boto3/textract-2018-06-27/StartDocumentTextDetection)in*AWSAPI-Referenz für SDK for Python (Boto3)*aus. 

------

Eine vollständige Liste vonAWSSDK-Entwicklerhandbücher und Codebeispiele finden Sie unter[Verwenden von Amazon Textract mit einemAWSSDK](sdk-general-information-section.md)aus. Dieses Thema enthält auch Informationen zu den ersten Schritten und Details zu früheren SDK-Versionen.