A simple package to help sort non-English names.
Project description
A simple package to help sort non-English names.
Free software: BSD 2-Clause License
Installation
pip install anglicize
You can also install the in-development version with:
pip install https://github.com/rciorba/python-anglicize/archive/master.zip
Documentation
This library provides one function, which takes a string and substitutes characters.
To use:
# call the function directly: anglicize("Łukasz") == "Lukasz" # or use it to sort a list: sorted(["Ana", "Łukasz", "Zack"], key=anglicize) == ["Ana", "Łukasz", "Zack"] # there we go, that's much better than this: sorted(["Ana", "Łukasz", "Zack"]) == ["Ana", "Zack", "Łukasz"]
Rationale
The purpose of this library is to help you sort non-English names writen in Latin-based alphabets.
Different languages have wildly different rules for sorting, for example Ö comes after Z in Finnish but after O in Hungarian. The approach taken here is to treat visually similar letters the same, so basically ÖÔÓÒṌṎ (and others) should all become O.
Handling letters that have little similarity to A-Z
The German ß is the main issue here. I chose to handle it like an S, mostly because it’s different enough from B (the most similar visually) and because it’s well known as a version of S to most Europeans.
Languages covered
Albanian
Azerbaijani
Bosnian
Bulgarian transliteration
Croatian
Dutch
Estonian
Finnish
French
Gagauz
German
Hungarian
Icelandic
Latvian
Lithuanian
Luxembourgish
Montenegrin
Norwegian
Polish
Portuguese
Romanian
Serbian
Spanish
Swedish
Tatar
Turkish
Turkmen
Contributing
Do you know a language written in a Latin alphabet and want to check it’s correctly handled? Have a look in tests/test_anglicize.py. If the language is there please check all “special” letters are handled. This list has been mostly compiled off of Wikipedia, so I would not be surprised to hear about errors :)
You can either make the changes and submit a PR or just create an issue mentioning - language - characters which need handling
Development
To run tests for all Python environments run:
tox
Changelog
0.0.3 (2020-03-08)
Fix rationale example.
0.0.2 (2020-03-08)
Fix readme example.
0.0.1 (2020-03-07)
First release on PyPI.
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
Built Distribution
File details
Details for the file anglicize-0.0.3.tar.gz
.
File metadata
- Download URL: anglicize-0.0.3.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ef7d3790d9ac82816dfceb5ad8c861783175ee007036e297fea27451d8d400e |
|
MD5 | 3dd2acb82609ccef2d834ee8c243cf8d |
|
BLAKE2b-256 | 064d16215fe29a176f4e05f970c851152e282b0851f36f328a6e2edf64911c91 |
File details
Details for the file anglicize-0.0.3-py2.py3-none-any.whl
.
File metadata
- Download URL: anglicize-0.0.3-py2.py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5165f141d3257bbd22b72b1e9847cfef7029e74b2a5bf0501e37111b2d2dc8cf |
|
MD5 | 83ec90ddb8fed0d6a6eef7a44885db13 |
|
BLAKE2b-256 | f838f8370795f6c5d93d842b1eb5b4a94e1d7490d122e19d5292d19688fb035c |