Skip to content

Instantly share code, notes, and snippets.

@Dhravya
Created January 23, 2022 10:48
Show Gist options
  • Save Dhravya/91298db58f1a4d314afc7c48d64d2996 to your computer and use it in GitHub Desktop.
Save Dhravya/91298db58f1a4d314afc7c48d64d2996 to your computer and use it in GitHub Desktop.
from typing import Sequence
def strong_british_accent(
text: Sequence
):
"""Converts your given string/array to a kind-of strong british accent (if you're nonsensical about it...)
"""
def brit(brsentence):
brsentence = brsentence.replace("it was ", "it was quite ")
# Words relating to ppl
brsentence = (
brsentence.replace("friend", "mate")
.replace("pal", "mate")
.replace("buddy", "mate")
.replace("person", "mate")
.replace("man", "mate")
.replace("people", "mates")
)
# Some weird past tense stuff i don't even know
brsentence = brsentence.replace("standing", "stood")
brsentence = brsentence.replace("sitting", "sat")
# Pronunciations of syllables
brsentence = brsentence.replace("o ", "oh ")
brsentence = brsentence.replace("ee", "ea")
brsentence = (
brsentence.replace("er ", "-a ")
.replace("er", "-a")
.replace("or ", "-a ")
.replace("or", "-a")
.replace("ar ", "-a ")
.replace("ar", "-a")
)
brsentence = brsentence.replace("a", "ah")
return brsentence
if not isinstance(text, str):
britished_msgs = map(brit, text)
return britished_msgs
msg = brit(text)
return msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment