Metadata-Version: 2.1
Name: docstruct
Version: 1.0.10
Summary: A package for representing documents as a tree of document, pages, paragraphs, lines, words, and characters
Home-page: https://github.com/smrt-co/docstruct
Author: Moran Nechushtan
Author-email: moran.n@trullion.com
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
Requires-Dist: pillow (>=8.1.1)
Requires-Dist: beautifulsoup4 (>=4.11.1)
Requires-Dist: numpy (>=1.23.2)
Requires-Dist: attrs (>=20.0.0)
Requires-Dist: pypdf2 (>=2.10.2)
Requires-Dist: reportlab (>=3.6.11)

<h1>Docstruct</h1>

<h2>Overview</h2>

<p>Docstruct is a package that parses the results of optical character recognition (OCR) algorithms, such as Tesseract (using the hOCR output) or Textract (AWS), into a tree structure. This tree structure allows for the visual representation of the document, with each node representing a document, page, paragraph, line, word, or character, along with its bounding box. The package also includes support for paragraph detection and text splitting that preserves logical units.</p>

<h2>Installation</h2>

<p>To install the Docstruct package, use the following pip command:</p>

<pre><code>pip install docstruct
</code></pre>

<h2>Usage</h2>

<p>To use the Docstruct package, simply import it and call the parsing function on your OCR results. For example:</p>

<pre><code>import docstruct

# Load the OCR results from a file
with open("ocr_results.hocr", "r") as f:
    ocr_results = f.read()

# Parse the OCR results into a tree structure
document = docstruct.parse(ocr_results)
</code></pre>

<p>Once you have a `document` object, you can access its individual elements, such as pages, paragraphs, and lines, using standard list indexing.</p>

<p>For example, to access the first page of the document, you can use the following code:</p>

<pre><code>first_page = document[0]
</code></pre>

<p>You can also visualize each element in the tree structure by calling the `show` method on an element. This will display a visual representation of the bounding boxes for each object.</p>

<p>For example:</p>

<pre><code>first_page.show()
</code></pre>

<p>For more information on how to use the Docstruct package, refer to the documentation and example code provided with the package.</p>

<h2>Contributions</h2>

<p>Contributions to the Docstruct package are always welcome. If you have a bug fix or a new feature, feel free to create a pull request on the GitHub repository.</p>

<h2>License</h2>

<p>The Docstruct package is licensed under the <a href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
