{"id":15396647,"url":"https://github.com/hupe1980/go-textractor","last_synced_at":"2025-04-16T00:18:41.962Z","repository":{"id":214192542,"uuid":"735253737","full_name":"hupe1980/go-textractor","owner":"hupe1980","description":"📄 Amazon textract response parser written in go.","archived":false,"fork":false,"pushed_at":"2024-01-06T20:21:11.000Z","size":6543,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T03:11:32.349Z","etag":null,"topics":["amazon","aws","golang","parser","textract","unstructured-data"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hupe1980.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-24T08:26:04.000Z","updated_at":"2024-10-07T04:47:56.000Z","dependencies_parsed_at":"2024-01-04T01:09:28.076Z","dependency_job_id":"0db7ca98-fa43-4579-8bf6-d4b9b2a11efd","html_url":"https://github.com/hupe1980/go-textractor","commit_stats":{"total_commits":29,"total_committers":2,"mean_commits":14.5,"dds":0.03448275862068961,"last_synced_commit":"f39d3202fd289f3762c696fdcd7d632c161e6c58"},"previous_names":["hupe1980/go-textractor"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hupe1980%2Fgo-textractor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hupe1980%2Fgo-textractor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hupe1980%2Fgo-textractor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hupe1980%2Fgo-textractor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hupe1980","download_url":"https://codeload.github.com/hupe1980/go-textractor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249173330,"owners_count":21224520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon","aws","golang","parser","textract","unstructured-data"],"created_at":"2024-10-01T15:34:28.218Z","updated_at":"2025-04-16T00:18:41.934Z","avatar_url":"https://github.com/hupe1980.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📄 go-textractor\n![Build Status](https://github.com/hupe1980/go-textractor/workflows/Build/badge.svg) \n[![Go Reference](https://pkg.go.dev/badge/github.com/hupe1980/go-textractor.svg)](https://pkg.go.dev/github.com/hupe1980/go-textractor)\n[![goreportcard](https://goreportcard.com/badge/github.com/hupe1980/go-textractor)](https://goreportcard.com/report/github.com/hupe1980/go-textractor)\n[![codecov](https://codecov.io/gh/hupe1980/go-textractor/branch/main/graph/badge.svg?token=VEDVMNI1TV)](https://codecov.io/gh/hupe1980/go-textractor)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\u003e Amazon textract response parser written in go.\n\n## Installation\nUse Go modules to include go-textractor in your project:\n```\ngo get github.com/hupe1980/go-textractor\n```\n\n## Usage\n```golang\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/aws/aws-sdk-go-v2/config\"\n\t\"github.com/aws/aws-sdk-go-v2/service/textract\"\n\t\"github.com/aws/aws-sdk-go-v2/service/textract/types\"\n\t\"github.com/hupe1980/go-textractor\"\n)\n\nfunc main() {\n\tfile, err := os.Open(\"examples/analyze_document/testfile.pdf\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tdefer file.Close()\n\n\tb, err := io.ReadAll(file)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tcfg, _ := config.LoadDefaultConfig(context.Background())\n\tclient := textract.NewFromConfig(cfg)\n\n\toutput, err := client.AnalyzeDocument(context.Background(), \u0026textract.AnalyzeDocumentInput{\n\t\tDocument: \u0026types.Document{\n\t\t\tBytes: b,\n\t\t},\n\t\tFeatureTypes: []types.FeatureType{\n\t\t\ttypes.FeatureTypeTables, types.FeatureTypeForms,\n\t\t},\n\t})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tdoc, err := textractor.ParseDocumentAPIOutput(\u0026textractor.DocumentAPIOutput{\n\t\tDocumentMetadata: output.DocumentMetadata,\n\t\tBlocks:           output.Blocks,\n\t})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Iterate over elements in the document\n\tfor _, p := range doc.Pages() {\n\t\t// Print lines and words\n\t\tfor _, l := range p.Lines() {\n\t\t\tfmt.Printf(\"Line: %s (%f)\\n\", l.Text(), l.Confidence())\n\t\t\tfor _, w := range l.Words() {\n\t\t\t\tfmt.Printf(\"Word: %s (%f)\\n\", w.Text(), w.Confidence())\n\t\t\t}\n\t\t}\n\n\t\t// Print tables\n\t\tfor _, t := range p.Tables() {\n\t\t\tfor r, row := range t.Rows() {\n\t\t\t\tfor c, cell := range row.Cells() {\n\t\t\t\t\tfmt.Printf(\"Table[%d][%d] = %s (%f)\\n\", r, c, cell.Text(), cell.Confidence())\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Print key values\n\t\tfor _, kv := range p.KeyValues() {\n\t\t\tfmt.Printf(\"Key: %s, Value: %s\\n\", kv.Key(), kv.Value())\n\t\t}\n\t}\n}\n```\n\nFor more example usage, see [examples](./examples).\n\n## Table extraction\n```golang\nf, err := os.Create(\"table.csv\")\nif err != nil {\n\tlog.Fatal(err)\n}\n\ndefer f.Close()\n\nif err := doc.Tables[0].ToCSV(f); err != nil {\n\tlog.Fatal(err)\n}\n```\n\n## Contributing\nContributions are welcome! Feel free to open an issue or submit a pull request for any improvements or new features you would like to see.\n\n## References\n- https://docs.aws.amazon.com/textract/latest/dg/\n- https://github.com/aws-samples/amazon-textract-textractor/\n- https://github.com/aws-samples/amazon-textract-response-parser/\n\n## License\nThis project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhupe1980%2Fgo-textractor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhupe1980%2Fgo-textractor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhupe1980%2Fgo-textractor/lists"}