Skip to main content

OCR-D framework - file format APIs and schemas

Project description

ocrd_models

OCR-D framework - file format APIs and schemas

See https://github.com/OCR-D/core

Adding user methods to the generated PAGE 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/get_FirstTextRegion.py
def get_FirstTextRegion(self):
  return self.get_TextRegion[0]

NOTE The method name and file name must be identical.

NOTE Do not use Python's % string interpolation operator, it will break generateDS. Use "".format(...) instead.

  1. Edit ocrd_models/ocrd_page_user_methods.py and append to the METHOD_SPECS list:
METHOD_SPECS = (
  # ...
  _add_method(r'^PageType$', 'get_FirstTextRegion')
  # ...
)
  1. Regenerate the PAGE API:
make generate-page

Project details


Release history Release notifications | RSS feed

This version

2.8.0

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.8.0.tar.gz (76.5 kB view hashes)

Uploaded Source

Built Distribution

ocrd_models-2.8.0-py3-none-any.whl (80.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page