PLD (PDF Language Detector) 
PLD is a Python program that analyzes PDF files, extracts images, processes them using Optical Character Recognition (OCR), and detects the dominant language of the text. It provides language detection information in JSON format and calculates the average confidence coefficient for each language.
Requirements
- Python 3.8 or above
- Tesseract OCR
- pdftoppm
Installation
Install Tesseract OCR and pdftoppm using your package manager. For example, on Ubuntu:
sudo apt install tesseract-ocr tesseract-ocr-all poppler-utils
From PyPi
Install with pip:
python3 -m pip install --user pdf-language-detector
Then run directly from your terminal:
pld --help
From the sources
Clone the PLD repository:
git clone git@github.com:github.com/icij/pld.git
Install the required Python packages with poetry:
poetry install
Then run inside a virtual env managed by poetry:
poetry run pld --help
From Docker
Install with Docker:
docker pull icij/pld
Then run inside a container:
docker run -it icij/pld pld --help
Usage
Detect
This command process PDF files and detect the dominant language.
pld detect --help
--language A list of ISO3 language codes to detect.
--input-dir: Path to the input directory containing PDF files. Default is the current directory.
--output-dir (optional): Path to the output directory. Default is 'out' directory in the current directory.
--max-pages (optional): Maximum number of pages to process per PDF file. Default is 5.
--resume (optional): Skip PDF files already analyzed.
--skip-images (optional): Skip the extraction of PDF files a images.
--skip-ocr (optional): Skip the OCR of images from PDF files.
--parallel (optional): Number of threads to run in parallel.
--relative-to (optional): Path to the directory relative to which build the output dir path.
Report
This command print a report from the previously detected language (using the same output dir).
pld report --help
--output-dir: Path to the output directory. Default is 'out' directory in the current directory.
Test
You can run the test suite (propulsed by pytest) with this command:
make test
Examples
Process PDF files in the current directory, detect English and Spanish languages, and save the results in the 'results' directory:
pld --language eng --language spa --input-dir documents --output-dir results
Process PDF files in the 'documents' directory, detect French and Greek languages, and limit the processing to 3 pages per file:
pld --language fra --language ell --input-dir documents --max-pages 3
License
This project is licensed under the MIT License.
Metadata
Release files for pdf-language-detector 0.0.11
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 |
|---|---|---|---|---|
| pdf_language_detector-0.0.11.tar.gz | 9.5 kB | Without provenance | Details for pdf_language_detector-0.0.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pdf_language_detector-0.0.11-py3-none-any.whl | Python 3 | none | any | Details for pdf_language_detector-0.0.11-py3-none-any.whl |
Total release size: 19.0 kB
Release files / pdf_language_detector-0.0.11.tar.gz
| Download URL | pdf_language_detector-0.0.11.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a483cf13d0d32d246c82671a8e1a49ea05cb01a6d635d59206f562bf2c59e76
|
|
BLAKE2b-256 checksum How to use checksums |
ed389b1cf4d9ae963d4a5bec0957da7b626be1de6fc8cb4dd7bc1aa9894681ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.10.6 Linux/5.19.0-45-generic
|
Release files / pdf_language_detector-0.0.11-py3-none-any.whl
| Download URL | pdf_language_detector-0.0.11-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c624a4fd8664a8e856a39bca1864b55b790111e6a17c023ca6b033bfeacd5fd
|
|
BLAKE2b-256 checksum How to use checksums |
9b97b2e42125a4ca9d5a8eaf4766b4bd97ff83e68711c591d97c62991afcb113
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.10.6 Linux/5.19.0-45-generic
|
Security for pdf-language-detector 0.0.11
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.