The ZIP Code Finder for Taiwan
This package lets you find ZIP code by address in Taiwan.
The main features:
- Fast. It builds ZIP code index by tokenization.
- Gradual. It returns partial ZIP code rather than noting when address is not detailed enoguh.
- Stand-alone. It depends on nothing.
Find ZIP code gradually:
>>> import zipcodetw >>> zipcodetw.find('臺北市') u'1' >>> zipcodetw.find('臺北市信義區') u'110' >>> zipcodetw.find('臺北市信義區市府路') u'110' >>> zipcodetw.find('臺北市信義區市府路1號') u'11008'
After v0.3, you even can find ZIP code like:
>>> zipcodetw.find('松山區') u'105' >>> zipcodetw.find('秀山街') u'' >>> zipcodetw.find('台北市秀山街') u'10042'
It is available on PyPI:
$ sudo pip install zipcodetw
Just install it and have fun. :)
Build Index Manually
If you install it by
python setup.py install, a ZIP code index
will be built automatically. But if you want to use it from source code, you
have to build an index manually:
$ python -m zipcodetw.builder
The ZIP code directory is provided by Chunghwa Post, and is available from: http://www.post.gov.tw/post/internet/Download/all_list.jsp?ID=2201#dl_txt_s_A0206
- Updated to the 3+3 v2102.01 data.
- Fixed a Python 3 bug, maybe.
- A black hole ate the logs.
- Updated the data to 2014/12.
- Fixed a rarely issue that causes IndexError.
- Reverted removing insignificant tokens introduced in v0.5.4.
- It now handles insignificant tokens; and
- redundant units in the finding logic (
- Allowed number token ends without unit.
address.tokensis a list.
- Fixed a gradual matching issue causing some wrong results.
- Removed the token whose unit is insignificant automatically.
- Fixed and simplified the matching logic for address tail.
- Refined the index building logic.
- Fixed the issue while it was running in multi-threaded environment.
- Added a new argument,
keep_alive, for the
- Refined the code slightly.
- It now builds a ZIP code index when you install it; so
- the package size is 12.5x smaller.
- The internal API is better now.
- It now shipped with an index compiled in SQLite; so
- initiation time is ~680x faster, i.e. ~30ms each import; and
zipcodetw.findis ~1.9x slower, i.e. ~2ms each call; and
- has bigger package size.
- All code was moved into
zipcodetw.findnow returns unicode instead of string.
- It builds full index for middle tokens; and
- also normalizes Chinese numerals now!
zipcodetw.findis ~1.06x faster.
- But initiation time increases to ~1.7x.
zipcodetw.findis 8x faster now!
- It has a better tokenizing logic; and
- a better matching logic for sub-number now.
- Internal API was changed a lot.
- The tests are better now.