https://github.com/aws-samples/amazon-textract-response-parser
Parse JSON response of Amazon Textract
https://github.com/aws-samples/amazon-textract-response-parser
amazon-textract
Last synced: 30 days ago
JSON representation
Parse JSON response of Amazon Textract
- Host: GitHub
- URL: https://github.com/aws-samples/amazon-textract-response-parser
- Owner: aws-samples
- License: apache-2.0
- Created: 2019-05-09T17:31:08.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-07-05T15:59:18.000Z (10 months ago)
- Last Synced: 2024-07-15T10:24:46.164Z (9 months ago)
- Topics: amazon-textract
- Language: TypeScript
- Homepage:
- Size: 16.5 MB
- Stars: 212
- Watchers: 15
- Forks: 95
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-aws-workshops - Parse JSON response of Amazon Textract
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](https://github.com/aws-samples/amazon-textract-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](src-python/README.md)
## JavaScript/TypeScript Usage
For documentation on usage see: [src-js/README.md](src-js/README.md)
## C# Usage
### Forms
```csharp
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
```csharp
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#](src-csharp/readme.md) samples
## Other Resources
- [Large scale document processing with Amazon Textract - Reference Architecture](https://github.com/aws-samples/amazon-textract-serverless-large-scale-document-processing)
- [Batch processing tool](https://github.com/aws-samples/amazon-textract-textractor)
- [Code samples](https://github.com/aws-samples/amazon-textract-code-samples)## License Summary
This sample code is made available under the Apache License V2.0 license. See the LICENSE file.