skip to navigation
skip to content

Not Logged In

zipcodetw 0.5.2

Find Taiwan ZIP code by address fuzzily.

Latest Version: 0.5.7

https://pypip.in/v/zipcodetw/badge.png?v=0.5.2 https://pypip.in/d/zipcodetw/badge.png?v=0.5.2

The ZIP Code Finder for Taiwan

This package lets you find ZIP code by address in Taiwan.

The main features:

  1. Fast. It builds ZIP code index by tokenization.
  2. Gradual. It returns partial ZIP code rather than noting when address is not detailed enoguh.
  3. Stand-alone. It depends on nothing.

Usage

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'

Installation

It is available on PyPI:

$ sudo pip install zipcodetw

Just install it and have fun. :)

Build Index Manually

If you install it by pip or 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

Data

The ZIP code directory is provided by Chunghwa Post, and is available from: http://www.post.gov.tw/post/internet/down/index.html#1808

Changelog

v0.5.2

  1. Fixed the issue while it was running in multi-threaded environment.
  2. Added a new argument, keep_alive, for the Directory class.

v0.5.1

  1. Refined the code slightly.

v0.5

  1. It now builds a ZIP code index when you install it; so
  2. the package size is 12.5x smaller.
  3. The internal API is better now.

v0.4

  1. It now shipped with an index compiled in SQLite; so
  2. initiation time is ~680x faster, i.e. ~30ms each import; and
  3. zipcodetw.find is ~1.9x slower, i.e. ~2ms each call; and
  4. has bigger package size.
  5. All code was moved into zipcodetw package.
  6. zipcodetw.find now returns unicode instead of string.

v0.3

  1. It builds full index for middle tokens; and
  2. also normalizes Chinese numerals now!
  3. zipcodetw.find is ~1.06x faster.
  4. But initiation time increases to ~1.7x.

v0.2

  1. zipcodetw.find is 8x faster now!
  2. It has a better tokenizing logic; and
  3. a better matching logic for sub-number now.
  4. zipcodetw.find_zipcodes was removed.
  5. Internal API was changed a lot.
  6. The tests are better now.
 
File Type Py Version Uploaded on Size
zipcodetw-0.5.2.tar.gz (md5) Source 2014-02-12 420KB
  • Downloads (All Versions):
  • 26 downloads in the last day
  • 164 downloads in the last week
  • 975 downloads in the last month