Skip to main content

Micro-library to normalize text strings

Project description

normality

Build Status

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


Download files

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

Source Distribution

normality-2.1.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

normality-2.1.1-py2.py3-none-any.whl (11.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file normality-2.1.1.tar.gz.

File metadata

  • Download URL: normality-2.1.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.1

File hashes

Hashes for normality-2.1.1.tar.gz
Algorithm Hash digest
SHA256 2c7cdb95737113d8f27ba287575945d6603ee3df4e847691839a71a53e1d1a95
MD5 702461c74714ebf195e64df614c0f6ad
BLAKE2b-256 94446a6beb3d70008c3ede6785e15772181f79a7d8366c912f8ca43cc056f53a

See more details on using hashes here.

File details

Details for the file normality-2.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: normality-2.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.1

File hashes

Hashes for normality-2.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 508daf0838ed58b5207242d112b48d9f157029f3faef1252d3837820340c8ed0
MD5 1e0c3e3da620a9c4e35a14a895cf8b43
BLAKE2b-256 7a2f59d30996e49300621c0ce9624f3f43ad1611e3774d57b551682335986989

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