Skip to main content

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(["Luke", "Łukasz", "Zan"], key=anglicize) == ["Luke", "Łukasz", "Zan"]

# 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 A in Norwegian. The approach taken here is to treat visually similar letters the same, so basically ÅÄĂÂ (and others) should all become A.

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.

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.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

anglicize-0.0.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anglicize-0.0.0-py2.py3-none-any.whl (4.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file anglicize-0.0.0.tar.gz.

File metadata

  • Download URL: anglicize-0.0.0.tar.gz
  • Upload date:
  • Size: 8.8 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

Hashes for anglicize-0.0.0.tar.gz
Algorithm Hash digest
SHA256 d2d66d117a989d0a37241f148a41a0362a64d1736733c55518db143decf0493c
MD5 7ff87790244dd05c6d430f89fd112c06
BLAKE2b-256 13d322eddb53aed6cee26ea5df665d4cadda39bbbebc05b627bbde647e8491eb

See more details on using hashes here.

File details

Details for the file anglicize-0.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: anglicize-0.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.3 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

Hashes for anglicize-0.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e0305625036e6e09930243e02291084ce97d611c555ca09bca3472579c949869
MD5 341e881a7e44ddaea2e9e8a45a3ba109
BLAKE2b-256 a00a88ee2e60cde62c4b1984990192e06475f0dad8d7d9515d9c112bca90b314

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page