def call_textract()

in workshops/AI_ML_services_workshop_information/lambda_code/ai_ml_services_lambda.py [0:0]


def call_textract(bucketname,filename):

    client = boto3.client('textract')
    x=client.detect_document_text(Document={'S3Object':{'Bucket':bucketname,'Name':filename}})
    the_blocks=x['Blocks']
    all_text=''
    for i in range(0,len(the_blocks)):
        try:
            if the_blocks[i]["BlockType"]=='WORD':
                the_text=the_blocks[i]['Text']
                all_text=all_text + " " + the_text
        except:
            pass
    return(all_text)