Quick start
From install to a normalised batch in about five minutes.
Requirements
Python 3.9 or newer. No compiled extensions, no runtime dependencies. The rule tables are
bundled in the wheel, so an offline install works as long as you have the .whl.
pip install petrock
python -c "import petrock; print(petrock.__version__)"
Parsing one address
from petrock import parse a = parse("Nad Oborou 1149/7, 16200 Praha 6 - Brevnov", country="cz") a.street # 'Nad Oborou' a.number # '1149/7' a.postcode # '16200' a.locality # 'Praha 6' a.district # 'Brevnov' a.confidence # 0.97
country= when you know it. Auto-detection works,
but on short inputs it guesses from the postcode shape alone and Czech and Slovak codes
overlap heavily.Batch mode
For anything above a few thousand rows use parse_many. It compiles the rule
table once and reuses it, which is roughly forty times faster than calling
parse in a loop.
from petrock import parse_many rows = [line.strip() for line in open("addresses.txt")] for src, addr in parse_many(rows, country="cz", workers=4): if addr.confidence < 0.6: print("check:", src)
Confidence
Every result carries a confidence between 0 and 1. It is not a probability —
it is the share of input tokens the parser could assign to a field. Anything above 0.85 is
safe to use unattended; between 0.5 and 0.85 is usually a real address with an unusual
suffix; below 0.5 means the parser mostly guessed.
Command line
petrock --country cz --in raw.csv --out clean.csv --column address petrock --country de --stdin < list.txt
The CLI writes the same fields as the Python API plus a petrock_confidence
column, and leaves every other column untouched.