OCR-D framework - file format APIs and schemas
Project description
ocrd_models
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:
-
Create a file
ocrd_models/ocrd_page_user_methods/get_FirstTextRegion.py
def get_FirstTextRegion(self): return self.get_TextRegion[0]
-
Edit
ocrd_models/ocrd_page_user_methods.py
and append to theMETHOD_SPECS
list:METHOD_SPECS = ( # ... _add_method(r'^PageType$', 'get_FirstTextRegion') # ... )
If the filename (sans the
.py
extension) does not match the method_name, you can provide an additionalfile_name
attribute to_add_method
:METHOD_SPECS = ( # ... _add_method(r'^PageType$', 'exportChildren', 'exportChildren_PageType') # ... )
Would add the method
exportChildren
from a fileexportChildren_PageType.py
.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! -
Regenerate the PAGE API:
make generate-page
See also: https://github.com/OCR-D/core
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
Built Distribution
Hashes for ocrd_models-2.49.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a1c9046ea2f8ecc5810b98213cad1445d76e78d0073571e039f33feef3f0d85 |
|
MD5 | 99220b11157a619693d8bf2593ab91ce |
|
BLAKE2b-256 | f4143f5cf55b791a0416e5420a2064198b07fcca6c188c9ee2a55e869963b54f |