Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

convert-us-to-uk-0.1.4.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

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

convert_us_to_uk-0.1.4-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file convert-us-to-uk-0.1.4.tar.gz.

File metadata

  • Download URL: convert-us-to-uk-0.1.4.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

Hashes for convert-us-to-uk-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3f0aff9230f210c44f52f53285a588f39d4b0658686f5b39953ba20db68c7d70
MD5 66420ba566bd47f42b1df3d9f9d8a385
BLAKE2b-256 fa3754f798678f9e2cdf7ef300a104564341083d70695457d8c4418ccd9126c2

See more details on using hashes here.

File details

Details for the file convert_us_to_uk-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for convert_us_to_uk-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f1d1d2ea457373132ea3379cd9b5378b5986916ed3e29ffe45d3bec7883023a3
MD5 8af225867b21c690f2ca76f3acbdad6b
BLAKE2b-256 38284d0ae107eb5954b9f85e455d1a2c71f918af580697968cbf980c3950591c

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