Skip to main content

Take unicode string, leave czech characters, normalize rest.

Project description

normalize_cz_unicode

https://badge.fury.io/py/normalize_cz_unicode.png https://pypip.in/d/normalize_cz_unicode/badge.png

Sanitize unicode inputs from unwanted characters.

Principle of the module is simple; Use translation table. If the character is not in translation table, convert it to latin2. If it can’t be converted, try to normalize it using unicode NKFD normalization. If it can’t be normalized, replace it with ?.

Usage

>>> from normalize_cz_unicode import normalize
>>> print normalize("Tohle je smajlík: 😭 , který tu ale nechci.")
Tohle je smajlík: ? , který tu ale nechci.

Various whitespace and special dash characters are normalized to basic ascii:

>>> a = u"Spojovníky ― a další havěť jako nedělitelné mezery taky nechci."
u'Spojovn\xedky \u2015 a dal\u0161\xed hav\u011b\u0165 jako ned\u011bliteln\xe9\u202fmezery\u2007taky nechci.'
>>> normalize(a)
u'Spojovn\xedky - a dal\u0161\xed hav\u011b\u0165 jako ned\u011bliteln\xe9 mezery taky nechci.'

Installation

Module is hosted at PYPI, and can be installed using PIP:

sudo pip install normalize_cz_unicode

Changelog

1.0.1

  • Added caching.

1.0.0

  • First working version.

  • Added tests.

  • Added documentation to README.rst.

  • Uploaded to PYPI.

0.1.0

  • Project created.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

normalize_cz_unicode-1.0.1.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file normalize_cz_unicode-1.0.1.tar.gz.

File metadata

File hashes

Hashes for normalize_cz_unicode-1.0.1.tar.gz
Algorithm Hash digest
SHA256 5a552a043105fe8079ad6e0a1e5f7494124bf233b5988caea013402f47cbd5c8
MD5 9ca1a0733212dafe91cd8903304920d7
BLAKE2b-256 37906815f724f70ade092855d53f88f7a32c482f1f01e958c8a9502b8926c118

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page