Skip to main content

Micro-library to normalize text strings

Project description

normality

build

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.2.3.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

normality-2.2.3-py2.py3-none-any.whl (12.4 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: normality-2.2.3.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for normality-2.2.3.tar.gz
Algorithm Hash digest
SHA256 cb7ff88348f090b8f5517baeda3d7cced94cebf6ae3e6756689a73d18b1bc041
MD5 9c31adeda3605cb99161dc073372bafb
BLAKE2b-256 f39b76d2f51a1dce19e9bc529ef71f8c61580a2fb91626a3fc6cea0d70fb4fba

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: normality-2.2.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for normality-2.2.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 645843f7630a4ccd4d4a50b89d8ba41a83aa9e386c1f615877e96202bb29ea13
MD5 a7a5285685482ca08ae8066e0c97626b
BLAKE2b-256 3f3612870cb0690a97a934c2353733257b57041179e80b7dbb7cd935aa11356b

See more details on using hashes here.

Provenance

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