Metadata-Version: 2.1
Name: readyocr
Version: 0.0.6
Summary: A nice package OCR for Amazon Textract and Google Document AI
Author-email: Sy An <syan.vn@gmail.com>
License: Copyright 2023 Sy An
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
        
        
Project-URL: Homepage, https://github.com/syanng/readyocr
Project-URL: Bug Tracker, https://github.com/syanng/readyocr/issues
Keywords: ocr,textract,documentai
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: typing-extensions
Requires-Dist: Pillow
Requires-Dist: pdf2image
Provides-Extra: all
Requires-Dist: amazon-textract-textractor ; extra == 'all'
Requires-Dist: google-cloud-documentai ; extra == 'all'
Provides-Extra: documentai
Requires-Dist: google-cloud-documentai ; extra == 'documentai'
Provides-Extra: textract
Requires-Dist: amazon-textract-textractor ; extra == 'textract'

# ReadyOCR

ReadyOCR is a Python library that allows you to quickly and easily parse data from various OCR API services, including AWS Textract and Google Document AI. The package also comes with nice features for searching and visualizing.

![Textract Output Visualize](images/visualize.png)

## Installation

You can install ReadyOCR using pip. Depending on the OCR API service you want to use, you can install the corresponding version of ReadyOCR:

* For minimal usage, if you only want to create ReadyOCR document object format:

    ```
    pip install "readyocr[all]"
    ```

* Or you can choose a specific version to support a specific API response:

    ```
    # support AWS Textract response
    pip install "readyocr[textract]"

    # support Google Document AI response
    pip install "readyocr[documentai]"

    # support all available
    pip install "readyocr[all]"
    ```

## Basic Usage

ReadyOCR allows you to create a Document object, which represents the OCR results. A Document can contain one or many pages, and each page can have multiple page entity objects, such as line, word, or table.

```
from readyocr.entities import Document, Page, Block, Paragraph, Line, Word, Table, Cell, Key, Value

document = Document(...)
page = Page(...)
word = Word(...)

# linking all object
page.children.add(word)
document.pages.append(page)
```

You can define any document structure you want by using the `.children` property for page entities. For example, a line object can have many word objects as children.

```
page = Page(...)
line = Line(...)
word1 = Word(...)
word2 = Word(...)

line.children = [word1, word2]

# add line object to page children
page.children.add(line)

# you can get descendant of a object
all_page_entity = page.descendant

# you can also filter all object by class, tag or attribute
all_word = page.descendant.filter_by_class(Word)
```

You can also use tags attribute to identify some specific attribute:

```
table = Table(...)
cell = Cell(...)
cell.tags.add('COLUMN_HEADER')
table.children.add(cell)

# Get all table cell which is column header
table.children.filter_by_tags('COLUMN_HEADER') 
```

### Examples

Please find all the available [examples](examples/) for better understanding ReadyOCR.

### License

ReadyOCR is released under the MIT license. See the [LICENSE](LICENSE) file for more details.
