A simple utility to convert US spelling to UK spelling.
Project description
convert-us-to-uk
A lightweight utility for quickly and effectively converting American English spellings to British English spellings inside a given string.
Installation
pip install convert-us-to-uk
Usage
from convert_us_to_uk.converter import convert_to_uk
text = "Colors are my favorite things."
uk_text = convert_to_uk(text)
print(uk_text)
# OUTPUT: "Colours are my favourite things."
Motivation
The motivation for this utility comes from the emergence of heavily used Large Language Models (LLMs), many of which struggle with the concept of writing English targeted at a UK-based audience.
With some refined prompting, you sometimes get the desired English dialect from LLMs, however this still relies on an element of good fortune (this is of course likely to change over time as LLMs continue to rapidly improve).
An effective but inefficient solution to this problem is to ask the LLM to re-write the text it outputted into the British dialect, however this comes at a computation cost.
convert-us-to-uk tackles this problem by speedily converting any American spellings into British English spellings by referring back to a set of conversion pairs (e.g. color maps to colours).
Limitations
This project focuses on only on spellings currently. This means that phrases such as "trash can" or "sidewalk" will not be replaced with British English counteparts. A potential extension of this library would be to include an optional parameter replace_phrase which can be set to True if the desired behaviour is to not only modify spellings, but also entire phrases.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file convert-us-to-uk-0.1.5.tar.gz.
File metadata
- Download URL: convert-us-to-uk-0.1.5.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3669d29fbf65e8da313057481398bde2f91076cb819fa1d27431dd7e89f94f82
|
|
| MD5 |
9db7328c6c4a40315efa43f69464d113
|
|
| BLAKE2b-256 |
b27c70acf40b2ac8a79683149d0574d7fcac5eb918b0920a2c3078395656e0d9
|
File details
Details for the file convert_us_to_uk-0.1.5-py3-none-any.whl.
File metadata
- Download URL: convert_us_to_uk-0.1.5-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cee6fa31b0856c3570e855e7d5cf026ba1e1f8debec652ad9c6b6b6d094aa32
|
|
| MD5 |
69206c93b7879d643f1214f6c042f49f
|
|
| BLAKE2b-256 |
e5351d1dfcc4ae433429aa222a986162705add5aac2cac003779136d8b9e0a87
|