1 Answer
- Newest
- Most votes
- Most comments
1
import boto3
import json
class TextractWrapper:
def __init__(self):
self.textract_client = boto3.client(
'textract',
aws_access_key_id='###############',
aws_secret_access_key='##################',
)
def analyze_document(self, feature_types, document_bytes):
try:
response = self.textract_client.analyze_document(
Document={'Bytes': document_bytes}, FeatureTypes=feature_types)
print("Se detectaron {} bloques.".format(len(response['Blocks'])))
except self.textract_client.exceptions.ServiceException as e:
print("Error al analizar el documento: {}".format(e))
raise
return response
textract = TextractWrapper()
document_file_name = r"C:\Users\cvict\Desktop\FinGlobal\DOC.jpg"
with open(document_file_name, 'rb') as document_file:
document_bytes = document_file.read()
feature_types = ['FORMS']
response = textract.analyze_document(feature_types, document_bytes)
response_json = json.dumps(response)
print(response_json)
answered a year ago
Relevant content
- asked 6 months ago
- asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago