OCR-D framework - file format APIs and schemas
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.pydef get_FirstTextRegion(self): return self.get_TextRegion[0]
-
Edit
ocrd_models/ocrd_page_user_methods.pyand append to theMETHOD_SPECSlist:METHOD_SPECS = ( # ... _add_method(r'^PageType$', 'get_FirstTextRegion') # ... )
If the filename (sans the
.pyextension) does not match the method_name, you can provide an additionalfile_nameattribute to_add_method:METHOD_SPECS = ( # ... _add_method(r'^PageType$', 'exportChildren', 'exportChildren_PageType') # ... )
Would add the method
exportChildrenfrom 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