Amazon Textract Caller tools
Project description
Textract-Caller
amazon-textract-caller provides a collection of ready to use functions and sample implementations to speed up the evaluation and development for any project using Amazon Textract.
Making it easy to call Amazon Textract regardless of file type and location.
def call_textract(input_document: Union[str, bytearray],
features: List[Textract_Features] = None,
output_config: OutputConfig = None,
kms_key_id: str = None,
job_tag: str = None,
notification_channel: NotificationChannel = None,
client_request_token: str = None,
return_job_id: bool = False,
force_async_api: bool = False) -> str:
Also useful when receiving the JSON response from an asynchronous job (start_document_text_detection or start_document_analysis)
def get_full_json(job_id: str = None,
textract_api: Textract_API = Textract_API.DETECT,
boto3_textract_client=None)->dict:
And when receiving the JSON from the OutputConfig location, this is useful as well.
def get_full_json_from_output_config(output_config: OutputConfig = None,
job_id: str = None,
s3_client = None)->dict:
Samples
Calling with file from local filesystem only with detect_text
textract_json = call_textract(input_document="/folder/local-filesystem-file.png")
Calling with file from local filesystem only detect_text and using in Textract Response Parser
(needs trp dependency throughpython -m pip install amazon-textract-response-parser
)
import json
from trp import Document
from textracthelper.t_call call_textract
textract_json = call_textract(input_document="/folder/local-filesystem-file.png")
d = Document(json.loads(response))
Calling with file from local filesystem with TABLES features
from textracthelper.t_call call_textract, Textract_Features
features = [Textract_Features.TABLES]
response = call_textract(
input_document="/folder/local-filesystem-file.png", features=features)
Call with images located on S3 but force asynchronous API
from textracthelper.t_call call_textract
response = call_textract(input_document="s3://some-bucket/w2-example.png", force_async_api=True)
Call with OutputConfig, Customer-Managed-Key
from textracthelper.t_call call_textract
from textractcaller.t_call import OutputConfig, Textract_Features
output_config = OutputConfig(s3_bucket="somebucket-encrypted", s3_prefix="output/")
response = call_textract(input_document="s3://someprefix/somefile.png",
force_async_api=True,
output_config=output_config,
kms_key_id="arn:aws:kms:us-east-1:12345678901:key/some-key-id-ref-erence",
return_job_id=False,
job_tag="sometag",
client_request_token="sometoken")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for amazon-textract-caller-0.0.10.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f0e6b02526300cfeaf8d9c775590f63f55c11bab8711a4ee344ce7cfc457ac6 |
|
MD5 | 003aa3db3c3b06ac34e82c28c68c7988 |
|
BLAKE2b-256 | a82f9643136ff37c2f9f15e4b8a1348018a65443b9deadddf434a3ea483a8b33 |
Close
Hashes for amazon_textract_caller-0.0.10-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63750e1e4d3f7a873c1d90d36c305d3d027e92da5029cd01655c5d55bc8b5c45 |
|
MD5 | d2191bd008e4478eb75f196c1438f26d |
|
BLAKE2b-256 | 20ad1a96817c311f5780e14f3cb28a13bceeb0f420aa591bfa136c32aa74555d |