Git Product home page Git Product logo

hocr-spec-python's Introduction

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>

hocr-spec-python's People

Contributors

kba avatar mittagessen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.