diff --git a/README.md b/README.md index c317ada..9d24038 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ A selection of quality-of-life tools for use with [pre-commit](https://github.co - [2.6.1 Configuration](#261-configuration) - [`.pre-commit-config.yaml` Configuration](#pre-commit-configyaml-configuration-1) - [Inline ignores](#inline-ignores) + - [The Dictionary](#the-dictionary) - [3. Development](#3-development) - [3.1 Testing](#31-testing) - [3.1.1 Testing scheme](#311-testing-scheme) @@ -381,6 +382,11 @@ def initialise(): # pragma: no americanise ``` +##### The Dictionary + +The default dictionary is stored in `src/americanise_hook/americanise_dictionary.py`. To add words, please open an MR on this repo. + + ## 3. Development ### 3.1 Testing diff --git a/src/americanise_hook/americanise.py b/src/americanise_hook/americanise.py index 049d9a6..01545ec 100755 --- a/src/americanise_hook/americanise.py +++ b/src/americanise_hook/americanise.py @@ -15,54 +15,7 @@ from typing import Union from src._shared import print_diff, resolvers - -DICTIONARY = { - # -se -> -ize - "characterise": "characterize", - "initialise": "initialize", - "instantiater": "instantiator", - "parametrise": "parametrize", - "prioritise": "prioritize", - "specialise": "specialize", - "organise": "organize", - # -yse -> -yze - "analyse": "analyze", - "catalyse": "catalyze", - # -our -> -or - "armour": "armor", - "behaviour": "behavior", - "colour": "color", - "flavour": "flavor", - "neighbour": "neighbor", - # -re -> -er - "centre": "center", - "fibre": "fiber", - "litre": "liter", - # -ae, -oe -> -e - "amoeba": "amoebae", - "anaesthesia": "anesthesia", - "caesium": "cesium", - # -ce -> -se - "defence": "defense", - # british uses "practice" as the noun and "practise" as the verb. US uses "practice" for both. - "practise": "practice", - # british uses "licence" as the noun and "license" as the verb. US uses "license" for both. - "licence": "license", - # -ge -> -g - "ageing": "aging", - "acknowledgement": "acknowledgment", - "judgement": "judgment", - # -ogue -> -og - "analogue": "analog", - "dialogue": "dialog", - # -l -> -ll - "fulfil": "fulfill", - "enrol": "enroll", - "skilful": "skillful", - # -ll -> -l - "labelled": "labeled", - "signalling": "signaling", -} +from src.americanise_hook.americanise_dictionary import DICTIONARY def _copy_case(target_string: str, input_string: str) -> str: diff --git a/src/americanise_hook/americanise_dictionary.py b/src/americanise_hook/americanise_dictionary.py new file mode 100644 index 0000000..3a13c24 --- /dev/null +++ b/src/americanise_hook/americanise_dictionary.py @@ -0,0 +1,51 @@ +# Copyright (c) 2025-2026 Benjamin Mummery + +"""The underlying dictionary for the Americanise hook.""" + +DICTIONARY = { + # -se -> -ize + "characterise": "characterize", + "initialise": "initialize", + "instantiater": "instantiator", + "parametrise": "parametrize", + "prioritise": "prioritize", + "specialise": "specialize", + "organise": "organize", + # -yse -> -yze + "analyse": "analyze", + "catalyse": "catalyze", + # -our -> -or + "armour": "armor", + "behaviour": "behavior", + "colour": "color", + "flavour": "flavor", + "neighbour": "neighbor", + # -re -> -er + "centre": "center", + "fibre": "fiber", + "litre": "liter", + # -ae, -oe -> -e + "amoeba": "amoebae", + "anaesthesia": "anesthesia", + "caesium": "cesium", + # -ce -> -se + "defence": "defense", + # british uses "practice" as the noun and "practise" as the verb. US uses "practice" for both. + "practise": "practice", + # british uses "licence" as the noun and "license" as the verb. US uses "license" for both. + "licence": "license", + # -ge -> -g + "ageing": "aging", + "acknowledgement": "acknowledgment", + "judgement": "judgment", + # -ogue -> -og + "analogue": "analog", + "dialogue": "dialog", + # -l -> -ll + "fulfil": "fulfill", + "enrol": "enroll", + "skilful": "skillful", + # -ll -> -l + "labelled": "labeled", + "signalling": "signaling", +}