• Stars
    star
    281
  • Rank 146,136 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Find Taiwan ZIP code by address fuzzily.

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/Download/all_list.jsp?ID=2201#dl_txt_s_A0206

Changelog

v0.6.5

  1. Updated to the 3+3 v2102.01 data.
  2. Fixed a Python 3 bug, maybe.

v0.6.2–0.6.4

  1. A black hole ate the logs.

v0.6.1

  1. Fixed the py2 py3 compatibility. Thanks the contribution from Poren Chiang and Ryan.

v0.6

  1. Updated the data to 2014/12.

v0.5.7

  1. Fixed a rarely issue that causes IndexError.

v0.5.6

  1. Reverted removing insignificant tokens introduced in v0.5.4.
  2. It now handles insignificant tokens; and
  3. redundant units in the finding logic (directory.find).
  4. Allowed number token ends without unit.
  5. Now address.tokens is a list.

v0.5.5

  1. Fixed a gradual matching issue causing some wrong results.

v0.5.4

  1. Removed the token whose unit is insignificant automatically.

v0.5.3

  1. Fixed and simplified the matching logic for address tail.
  2. Refined the index building logic.

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.

More Repositories

1

uniout

Never see escaped bytes in output.
Python
158
star
2

clime

DEPRECATION: Convert functions into multi-command program breezily.
Python
151
star
3

mosql

Build SQL with native Python data structure smoothly.
Python
140
star
4

mosky-mini-configs

The configs just work. ✨
Shell
91
star
5

hypothesis-testing-with-python

True difference or noise? 📊
Jupyter Notebook
70
star
6

mosky.vim

DEPRECATE: This repo is merged into moskytw/mosky-mini-configs.
Vim Script
47
star
7

elegant-concurrency-lab

Make concurrency elegant with channels.
Python
43
star
8

practicing-python-3

Learn Python from zero to intermediate! 🚀
Jupyter Notebook
37
star
9

data-science-with-python

Introduce data science in plain Python. 🧪
Jupyter Notebook
35
star
10

git-count

Python
28
star
11

revivalkit

Python
26
star
12

slak

Collect data from Slack like a pro. ⚡️
Python
24
star
13

statistical-regression-with-python

Explain & predict! 📈
Jupyter Notebook
15
star
14

postbox

Python
13
star
15

mining-ptt-news

What kind of news will be voted down on PTT?
Jupyter Notebook
13
star
16

luthadel.vim

A simple but ardent Vim color scheme.
Vim Script
11
star
17

nginx-contrib-vim

Make Vim have better nginx.conf support.
Vim Script
9
star
18

enhancedyaml

Python
8
star
19

cython-lab

Python
7
star
20

uwsgi-emperor

7
star
21

coding-is-magic

Magic! ✨
Jupyter Notebook
5
star
22

examples-for-learning-python-from-data

Python
4
star
23

concurrency-lab

Python
4
star
24

memo-app

JavaScript
4
star
25

multi-celeryd

4
star
26

tacit

Python
2
star
27

snack

Python
1
star
28

tagit.vim

It is a vim plugin handles tags in background. Let you enjoy the benfits of tags without addational effort.
Vim Script
1
star
29

vim-color-scheme-template-generator

Generate Vim's color scheme template precisely.
Python
1
star
30

examples-for-programming-with-python

Python
1
star