Skip to main content

Text Quality

A package to determine the quality of a a digitized text, from a handwritten script or scanned print (HTR/OCR output).

The current pipeline is tuned on (historic) Dutch language, and will not perform well on other languages. However, the underlying model has been used for other (Germanic) languages, and can be adapted and applied to texts of other languages and time periods.

Examples

Good quality (not necessarily perfect):

Van
Malacca den 29 maart 1.
door zoo veel ruijmer handen te hebben,
[…]
Siac van waar op den 5=e deeser,
na onse verschijde adhortaties, is over
eeen gekomen
zoo meede van Siac

Bad quality:

uijtkoops --
winst suijverevense versis
e ee
,, 19
1 oe
na aftrek van
5 p:s C: Commiss:s
t 1a per 't geheel t p=s lb. off @'t geheeke
[…]

What's Missing

  • Pipelines for languages other than historic Dutch
  • Automatic training procedure for creating and update pipelines
  • Additional features such as publication year.

See this notebook for a semi-automated pipeline creation process.

How to use text_quality

After installation, use the classify_text_quality.py script to classify PageXML or plain text files. For instance, if you want to classify all *.xml files in the pages/ directory, use the --glob argument:

classify_text_quality.py --glob "page/*.xml" --output classifications.csv --output-scores

Per input file, one output line is returned in CSV table format, along with the classification result:

  1. Good quality
  2. Medium quality
  3. Bad quality

All supported parameters:

$ classify_text_quality.py --help
usage: Classify the quality of a (digitized) text. [-h] [--input [FILE ...]] [--pagexml [FILE ...]] [--pagexml-glob PATTERN] [--output FILE] [--output-scores]

options:
  -h, --help            show this help message and exit
  --output FILE, -o FILE
                        Output file; defaults to stdout.
  --output-scores       Output scores and text statistics.

Input:
  --input [FILE ...], -i [FILE ...]
                        Plain text file(s) to classify. Use '-' for stdin.
  --pagexml [FILE ...]  Input file(s) in PageXML format.
  --pagexml-glob PATTERN, --glob PATTERN
                        A pattern to find a set of PageXML files, e.g. 'pagexml/*.xml'.

Notes

The pipeline might emit warnings like this:

UserWarning: X does not have valid feature names, but MLPClassifier was fitted with feature names

This is due to the internals of the Scikit-Learn Pipeline object, and can safely be ignored.

The dependencies are pinned to specific versions. While this prevents implicit updated even for patch-level updated of required libraries, it prevents misleading warnings emitted by varying Scikit-Learn versions. Hence, requirement dependecies can be changed manually, if you are aware of these issues.

The project setup is documented in project_setup.md. Feel free to remove this document (and/or the link to this document) if you don't need it.

Installation

To install the text_quality package:

pip install -U text-quality

Alternatively, install the package from GitHub repository:

git clone https://github.com/LAHTeR/htr-quality-classifier.git
cd htr-quality-classifier
python3 -m pip install -U .

Documentation

Readthedocs

Contributing

If you want to contribute to the development of text_quality, have a look at the contribution guidelines.

Credits

Logic and implementation are based on Nautilus-OCR.

This package was created with Cookiecutter and the NLeSC/python-template.

Badges

(Customize these badges with your own links, and check https://shields.io/ or https://badgen.net/ to see which other badges are available.)

fair-software.eu recommendations
(1/5) code repository github repo badge
(2/5) license github license badge
(3/5) community registry RSD workflow pypi badge
(4/5) citation DOI
(5/5) checklist workflow cii badge
howfairis fair-software badge
Other best practices  
Static analysis workflow scq badge
Coverage workflow scc badge
Documentation Documentation Status
GitHub Actions  
Build build
Citation data consistency cffconvert
SonarCloud sonarcloud
MarkDown link checker markdown-link-check

Release files for text-quality 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for text-quality 0.2.0
File Size Uploaded
text_quality-0.2.0.tar.gz 2.5 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for text-quality 0.2.0
File Interpreter ABI Platform
text_quality-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size:4.9 MB

Release files / text_quality-0.2.0.tar.gz

Download URL text_quality-0.2.0.tar.gz
Size 2.5 MB
Tags Source
SHA-256 checksum
How to use checksums
4a7aa26547ee1ffabd88e24440f6d71be9c521f1ae243690104b61bd34555d93
BLAKE2b-256 checksum
How to use checksums
9385125e57a12815457db8001a6899e8b04bbb58e5ee839ddbc6dbb84e62852c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / text_quality-0.2.0-py3-none-any.whl

Download URL text_quality-0.2.0-py3-none-any.whl
Size 2.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
7ce4a245218e3c83f3f1fb662c7abf29764f55db517b7f526e8cf8c016ed65b0
BLAKE2b-256 checksum
How to use checksums
8fda03c10ddadd63f2fc6fe3a4843ecc5164f6d3c160edd45274c1165ef72b54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

This release

0.2.0 This release

2 release files

0.1.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page