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:
- 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 additional file_name
attribute to _add_method
:
METHOD_SPECS = (
# ...
_add_method(r'^PageType$', 'exportChildren', 'exportChildren_PageType')
# ...
)
Would add the method exportChildren
from a file exportChildren_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
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.22.3b1.tar.gz
(84.6 kB
view hashes)
Built Distribution
ocrd_models-2.22.3b1-py3-none-any.whl
(157.0 kB
view hashes)
Close
Hashes for ocrd_models-2.22.3b1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ee889925b5812811ff96518a2c08fd6b555a64c60d3f15dd829378ee2114de0 |
|
MD5 | 1d09fcccbe16dcaa7ca48d348673e221 |
|
BLAKE2b-256 | 448b2ce18e39087f8efe1420b16e121f0e31902bb090ba23a260e13993c08b21 |