1개 답변
- 최신
- 최다 투표
- 가장 많은 댓글
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)
답변함 일 년 전
관련 콘텐츠
- AWS 공식업데이트됨 2년 전