Micro-library to normalize text strings
Project description
normality
Normality is a Python micro-package that contains a small set of text normalization functions for easier re-use. These functions accept a snippet of unicode or utf-8 encoded text and remove various classes of characters, such as diacritics, punctuation etc. This is useful as a preparation to further text analysis.
WARNING: This library works much better when used in combination
with pyicu
, a Python binding for the International Components for
Unicode C library. ICU provides much better text transliteration than
the default text-unidecode
.
Example
# coding: utf-8
from normality import normalize, slugify, collapse_spaces
text = normalize('Nie wieder "Grüne Süppchen" kochen!')
assert text == 'nie wieder grune suppchen kochen'
slug = slugify('My first blog post!')
assert slug == 'my-first-blog-post'
text = 'this \n\n\r\nhas\tlots of \nodd spacing.'
assert collapse_spaces(text) == 'this has lots of odd spacing.'
License
normality
is open source, licensed under a standard MIT license
(included in this repository as LICENSE
).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for normality-2.3.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a249b2c761274ac11e4a3bf2d08fa0a78853d59b5406216a65fe2b99cd0f43d1 |
|
MD5 | 2f9c037c5a576591baa99ba3a9212f9a |
|
BLAKE2b-256 | 020595f8eb0a38fdfede671667ab40e2da41ede746e8a43c4e20f183e05ae6b0 |