hocr-spec-python
Validation of hOCR close to the specs
Rationale
hOCR is a flavor of HTML for encoding the results of Optical Character Recognition (OCR) engines. It is supported by most OCR engines, such as tesseract, ocropus/ocropy and kraken.
The hOCR specifications is at the same time very simple (hOCR is just HTML) and hard to implement, due to its terseness and lack of up-to-date code samples. This project aims to implement the rules defined by the specs from the ground up to serve as a validation tool and reference implementation. It is meant to help hOCR implementers and support tools like hocr-tools.
Installation
Use pip:
# System-wide:
sudo pip install [--user] hocr-spec
# For current user:
pip install --user hocr-spec
From source:
git clone https://github.com/kba/hocr-spec-python
cd hocr-spec-python
# System-wide:
sudo python setup.py install
# For current user:
python setup.py install --user
Command line interface
usage: hocr-spec [-h] [--format {text,bool,ansi,xml}]
[--profile {relaxed,standard}]
[--implicit_capabilities CAPABILITY]
[--skip-check {attributes,classes,metadata,properties}]
[--parse-strict] [--silent]
sources [sources ...]
positional arguments:
sources hOCR file to check or '-' to read from STDIN
optional arguments:
-h, --help show this help message and exit
--format {text,bool,ansi,xml}, -f {text,bool,ansi,xml}
Report format
--profile {relaxed,standard}, -p {relaxed,standard}
Validation profile
--implicit_capabilities CAPABILITY, -C CAPABILITY
Enable this capability. Use '*' to enable all
capabilities. In addition to the 'ocr*' classes, you
can use ['ocrp_dir', 'ocrp_font', 'ocrp_lang',
'ocrp_nlp', 'ocrp_poly']
--skip-check {attributes,classes,metadata,properties}, -X {attributes,classes,metadata,properties}
Skip one check
--parse-strict Parse HTML with less tolerance for errors
--silent, -s Don't produce any output but signal success with exit
code.
API example
from hocr_spec import HocrValidator
validator = HocrValidator()
report = validator.validate('/path/to/sample.hocr')
print(report.format('xml'))
# <report valid='false'>...</report>
Metadata
Release files for hocr-spec 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hocr-spec-0.2.0.tar.gz | 12.8 kB | Without provenance | Details for hocr-spec-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hocr_spec-0.2.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for hocr_spec-0.2.0-py2.py3-none-any.whl |
Total release size: 25.9 kB
Release files / hocr-spec-0.2.0.tar.gz
| Download URL | hocr-spec-0.2.0.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0c4b5ab8a448fa090264784f6ede307483f10f700fda859fcc5bb8772130f099
|
|
BLAKE2b-256 checksum How to use checksums |
03bf8cf264162ce1cda47f95e8aa8822c7563a17aee0d1beacea0e91b4febc78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/2.7.9
|
Release files / hocr_spec-0.2.0-py2.py3-none-any.whl
| Download URL | hocr_spec-0.2.0-py2.py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ddb72fada2e7960eadd2f3a5215e587e89f06d9be94db86e9a990eb2102baa32
|
|
BLAKE2b-256 checksum How to use checksums |
ea36ab3bc452f48469c90389a0f093284c0750df8234854ffff09a3819da9d5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/2.7.9
|
Security for hocr-spec 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.