Python library for Iraqi vehicle plate normalization, parsing, validation, formatting, and comparison.
Project description
iraqi-plate
A Python library for parsing, normalizing, validating, formatting, and comparing Iraqi vehicle plate numbers.
It supports two acceptance modes:
strictstandard
It also supports legacy Arabic-letter input in standard mode, returning a canonical normalized value with a legacy warning.
Features
- Normalize current Iraqi plate numbers into canonical form.
- Parse structural input into explicit components.
- Validate user input and return machine-readable issues.
- Format canonical or parsed plates into canonical, display, or compact styles.
- Compare two inputs by canonical identity.
- Handle separator cleanup and Eastern Arabic digit folding.
Installation
pip install iraqi-plate
Quick start
from iraqi_plate import IraqiPlateService, PlateOptions, AcceptanceMode, FormatStyle
svc = IraqiPlateService()
result = svc.normalize_plate("A22153")
print(result.success)
print(result.canonical)
legacy = svc.normalize_plate("ا٢٢١٥٣")
print(legacy.success)
print(legacy.canonical)
print(legacy.warnings)
formatted = svc.format_plate("22A153", style=FormatStyle.DISPLAY)
print(formatted)
same = svc.equals("A22153", "22A153")
print(same)
strict_result = svc.validate_plate(
"22-A-153",
options=PlateOptions(mode=AcceptanceMode.STRICT),
)
print(strict_result.is_valid)
API
normalize_plate(input, options=None)
Returns NormalizeResult with:
successcanonicalplatecorrectionserrorswarnings
parse_plate(input, options=None)
Returns ParseResult with structural parsing results.
validate_plate(input, options=None)
Returns ValidationResult with:
is_validplateissues
format_plate(input_or_plate, style=FormatStyle.CANONICAL, options=None)
Supported styles:
canonicaldisplaycompact
equals(a, b, options=None)
Compares two inputs by canonical identity.
Accepted formats
Strict mode
After cleanup, only canonical current format is accepted:
GGAN{1-5}
Where:
GGis between11and29Ais a Latin uppercase letterNis1..5ASCII digits
Standard mode
Accepted inputs include:
- canonical current:
22A153 - shorthand letter first:
A22153 - shorthand digit first:
22153A - legacy Arabic letter first:
ا22153
Legacy inputs are accepted with a legacy_number warning and normalized into canonical identity like:
22ا153
Development
Create a virtual environment, install dev dependencies, then run:
python -m pip install -e .[dev]
pytest
python -m build
Project metadata
- Author: Osama Samman, OpenAI
- Repository: https://github.com/mg-jordan/vehichle-plate-normalization/tree/py/iraqi-plate
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iraqi_plate-0.1.1.tar.gz.
File metadata
- Download URL: iraqi_plate-0.1.1.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca42c0ddaa4f72569902577a7083d60d4d73c5dc50a9d05cb8dbdb06e42f702a
|
|
| MD5 |
cfcf786e84965e19c2b7a72206466cb0
|
|
| BLAKE2b-256 |
79f08c35d41305f31cfe2901087fcbe99b554bbd2a2787e16d3edb9dca3314a5
|
File details
Details for the file iraqi_plate-0.1.1-py3-none-any.whl.
File metadata
- Download URL: iraqi_plate-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42e23b702cfd93c4b3daae8c9f84cc71ba29329d4dfa6237bb3eb912f6db849b
|
|
| MD5 |
5e487c4003545db32c8191f26b082991
|
|
| BLAKE2b-256 |
bdef846e14a42c17d8586966dfc9dc7654b4f2765c39a60da35b6a3938cf06c3
|