MCPcopy Index your code
hub / github.com/aws-samples/amazon-textract-response-parser

github.com/aws-samples/amazon-textract-response-parser @v0.1.16

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.16 ↗ · + Follow
669 symbols 1,038 edges 32 files 59 documented · 9%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Textract Response Parser

You can use Textract response parser library to easily parse JSON returned by Amazon Textract. The library parses JSON and provides programming language specific constructs to work with different parts of the document. textractor is an example of a PoC batch processing tool that takes advantage of the Textract response parser library and generates output in multiple formats.

Python Usage

For documentation on usage see: src-python/README.md

JavaScript/TypeScript Usage

For documentation on usage see: src-js/README.md

C# Usage

Forms

document.Pages.ForEach(page => {
    Console.WriteLine("Print Lines and Words:");
    page.Lines.ForEach(line => {
        Console.WriteLine("{0}--{1}", line.Text, line.Confidence);
        line.Words.ForEach(word => {
            Console.WriteLine("{0}--{1}", word.Text, word.Confidence);
        });
    });
    Console.WriteLine("Print Fields:");
    page.Form.Fields.ForEach(f => {
        Console.WriteLine("Field: Key: {0}, Value {1}", f.Key, f.Value);
    });
    Console.WriteLine("Get Field by Key:");
    var key = "Phone Number:";
    var field = page.Form.GetFieldByKey(key);
    if(field != null) {
        Console.WriteLine("Field: Key: {0}, Value: {1}", field.Key, field.Value);
    }
});

Tables

document.Pages.ForEach(page => {
    page.Tables.ForEach(table => {
        var r = 0;
        table.Rows.ForEach(row => {
            r++;
            var c = 0;
            row.Cells.ForEach(cell => {
                c++;
                Console.WriteLine("Table [{0}][{1}] = {2}--{3}", r, c, cell.Text, cell.Confidence);
            });
        });
    });
});

Check out the src-csharp folder for instructions on how to run .NET Core C# samples

Other Resources

License Summary

This sample code is made available under the Apache License V2.0 license. See the LICENSE file.

Extension points exported contracts — how you extend this code

ApiDocumentMetadata (Interface)
(no doc)
src-js/src/api-models/response.ts
ApiAnalyzeExpenseResponse (Interface)
(no doc)
src-js/src/api-models/response.ts
ApiResponseWithContent (Interface)
(no doc)
src-js/src/api-models/response.ts
ApiAnalyzeDocumentResponse (Interface)
(no doc)
src-js/src/api-models/response.ts
ApiDetectDocumentTextResponse (Interface)
(no doc)
src-js/src/api-models/response.ts

Core symbols most depended-on inside this repo

pageNumber
called by 24
src-js/src/expense.ts
get_block_by_id
called by 23
src-python/trp/trp2.py
getIterable
called by 11
src-js/src/base.ts
add_page_orientation
called by 9
src-python/trp/t_pipeline.py
iterDocs
called by 8
src-js/src/expense.ts
lineAtIndex
called by 7
src-js/src/document.ts
tableAtIndex
called by 7
src-js/src/document.ts
str
called by 6
src-js/src/document.ts

Shape

Method 441
Class 134
Function 41
Interface 27
Route 20
Enum 6

Languages

Python53%
TypeScript38%
C#9%

Modules by API surface

src-js/src/document.ts128 symbols
src-python/trp/trp2.py116 symbols
src-python/trp/__init__.py95 symbols
src-js/src/expense.ts53 symbols
src-python/a2i/a2irp.py52 symbols
src-csharp/TextractExtensions.cs52 symbols
src-python/trp/trp2_expense.py50 symbols
src-js/src/geometry.ts30 symbols
src-python/tests/test_trp2.py15 symbols
src-js/src/api-models/document.ts13 symbols
src-js/src/api-models/response.ts11 symbols
src-csharp/Program.cs11 symbols

For agents

$ claude mcp add amazon-textract-response-parser \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact