Skip to main content

OCR-D framework - file format APIs and schemas

Project description


OCR-D framework - file format APIs and schemas

Adding user methods to the generated OcrdPage API

Let's say you want to add a method get_FirstTextRegion on the pc:Page element:

  1. Create a file ocrd_models/ocrd_page_user_methods/

    def get_FirstTextRegion(self):
        return self.get_TextRegion[0]
  2. Edit ocrd_models/ and append to the METHOD_SPECS list:

        # ...
        _add_method(r'^PageType$', 'get_FirstTextRegion')
        # ...

    If the filename (sans the .py extension) does not match the method_name, you can provide an additional file_name attribute to _add_method:

        # ...
        _add_method(r'^PageType$', 'exportChildren', 'exportChildren_PageType')
        # ...

    Would add the method exportChildren from a file

    Note: The method name in the file must match the method name passed to _add_method. This is not checked automatically, so double-check manually!

  3. Regenerate the PAGE API:

    make generate-page

See also:

Project details

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ocrd_models-2.42.0.tar.gz (99.6 kB view hashes)

Uploaded source

Built Distribution

ocrd_models-2.42.0-py3-none-any.whl (104.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page