A Python port of the Apache Lucene ASCII Folding Filter that converts alphabetic, numeric, and symbolic Unicode characters which are not in the first 127 ASCII characters (the ‘Basic Latin’ Unicode block) into ASCII equivalents, if they exist.
A Python port of the Apache Lucene ASCII Folding Filter that converts alphabetic, numeric, and symbolic Unicode characters which are not in the first 127 ASCII characters (the "Basic Latin" Unicode block) into ASCII equivalents, if they exist.
> from fold_to_ascii import fold > s = u'Astroturf® paté' > fold(s) u'Astroturf pate' > fold(s, u'?') u'Astroturf? pate'
Differences from JS fold-to-ascii
This library always removes astral characters, even when a replacement character is specified. PRs welcome if you want to fix this.
Differences from unidecode
There are a few Python unidecode libraries out there
2). They are based on a Perl program
that makes some interesting choices about what to replace, for example,
POUND SIGN) is replaced with the string
PS. Also, they do not allow
specifying a replacement character to use other than the empty string for
$ virtualenv -p python3 ~/.local/venvs/fold_to_ascii $ source ~/.local/venvs/fold_to_ascii/bin/activate $ pip install -r requirements.txt
$ make lint && make test
Requires a pypi account.
- Bump the version in setup.py.
- Build and upload:
$ python setup.py sdist bdist_wheel $ twine upload dist/*
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size fold_to_ascii-1.0.2.post1-py3-none-any.whl (22.6 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size fold_to_ascii-1.0.2.post1.tar.gz (22.7 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for fold_to_ascii-1.0.2.post1-py3-none-any.whl
Hashes for fold_to_ascii-1.0.2.post1.tar.gz