From c039f3ecf9bef08d2f2ec7f7071a8cd48ea30a82 Mon Sep 17 00:00:00 2001 From: Bradley Reynolds Date: Sun, 24 Mar 2024 05:05:13 +0000 Subject: [PATCH 1/8] Move repeated assignment into list Signed-off-by: GitHub --- src/imsosorry/uwuification.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/imsosorry/uwuification.py b/src/imsosorry/uwuification.py index cf8a6d4..b8ec69d 100644 --- a/src/imsosorry/uwuification.py +++ b/src/imsosorry/uwuification.py @@ -4,6 +4,7 @@ import random import re +from copy import copy from functools import partial WORD_REPLACE = { @@ -146,15 +147,19 @@ def uwuify( if len(text) < max_emojifiable_len and not alpha: return random.choice(EMOJIS) - original_text = text.lower() - text = text.lower() - text = word_replace(text) - text = nyaify(text) - text = char_replace(text) - text = stutter(text, stutter_strength) - text = emoji(text, emoji_strength) - text = tildify(text, tilde_strength) + original_text = copy(text) + + transforms = [ + word_replace, + nyaify, + char_replace, + partial(stutter, strength=stutter_strength), + partial(emoji, strength=emoji_strength), + partial(tildify, strength=tilde_strength), + ] + for transform in transforms: + text = transform(text) if text == original_text and alpha: text = uwuify( From 87dfbad3d2d9200dcf7f50d1f15bf8fc7b5327cc Mon Sep 17 00:00:00 2001 From: Bradley Reynolds Date: Sun, 24 Mar 2024 05:06:13 +0000 Subject: [PATCH 2/8] Rename variables Signed-off-by: GitHub --- src/imsosorry/uwuification.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/imsosorry/uwuification.py b/src/imsosorry/uwuification.py index b8ec69d..9eca965 100644 --- a/src/imsosorry/uwuification.py +++ b/src/imsosorry/uwuification.py @@ -139,12 +139,12 @@ def uwuify( stutter_strength: float = 0.2, emoji_strength: float = 0.1, tilde_strength: float = 0.1, - max_emojifiable_len: int = 2, + minimun_processable_length: int = 2, ) -> str: """Take a string and returns an uwuified version of it.""" - alpha = any(char.isalpha() for char in text) + contains_alpha = any(char.isalpha() for char in text) - if len(text) < max_emojifiable_len and not alpha: + if len(text) < minimun_processable_length and not contains_alpha: return random.choice(EMOJIS) text = text.lower() @@ -161,7 +161,7 @@ def uwuify( for transform in transforms: text = transform(text) - if text == original_text and alpha: + if text == original_text and contains_alpha: text = uwuify( text, stutter_strength=stutter_strength + 0.225, From 07ff0c0938970ccabccc6392bac394d5b3c8f0dc Mon Sep 17 00:00:00 2001 From: Bradley Reynolds Date: Sun, 24 Mar 2024 05:07:08 +0000 Subject: [PATCH 3/8] Properly return recursion Signed-off-by: GitHub --- src/imsosorry/uwuification.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/imsosorry/uwuification.py b/src/imsosorry/uwuification.py index 9eca965..ecdfb94 100644 --- a/src/imsosorry/uwuification.py +++ b/src/imsosorry/uwuification.py @@ -162,7 +162,7 @@ def uwuify( text = transform(text) if text == original_text and contains_alpha: - text = uwuify( + return uwuify( text, stutter_strength=stutter_strength + 0.225, emoji_strength=emoji_strength + 0.075, From 1ec80254b9e265454ea43410d188fc7e05ea731e Mon Sep 17 00:00:00 2001 From: Bradley Reynolds Date: Sun, 24 Mar 2024 05:54:02 +0000 Subject: [PATCH 4/8] Replace unique functions with two generic functions Signed-off-by: GitHub --- src/imsosorry/uwuification.py | 89 +++++++++++++++-------------------- 1 file changed, 39 insertions(+), 50 deletions(-) diff --git a/src/imsosorry/uwuification.py b/src/imsosorry/uwuification.py index ecdfb94..0413201 100644 --- a/src/imsosorry/uwuification.py +++ b/src/imsosorry/uwuification.py @@ -6,6 +6,10 @@ import re from copy import copy from functools import partial +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from collections.abc import Callable WORD_REPLACE = { "small": "smol", @@ -57,7 +61,7 @@ """A list of emojis/emoticons to add.""" REGEX_WORD_REPLACE = re.compile(r"(? str: return text -def char_replace(text: str) -> str: - """Replace certain characters with 'w'.""" - return REGEX_WORD_REPLACE.sub("w", text) - - -def stutter_replace(match: re.Match[str], strength: float = 0.0) -> str: - """Replace a single character with a stuttered character.""" - match_string = match.group() - if random.random() < strength: - # Stutter the last character - return f"{match_string}-{match_string[-1]}" - return match_string - - -def stutter(text: str, strength: float) -> str: - """Add stuttering to a string.""" - return REGEX_STUTTER.sub(partial(stutter_replace, strength=strength), text, 0) - - -def nyaify(text: str) -> str: - """Nyaify a string by adding a 'y' between an 'n' and a vowel.""" - return REGEX_NYA.sub(SUBSTITUTE_NYA, text, 0) +def stutter_string(text: str) -> str: + """Repeat the last character in a string.""" + return f"{text}-{text[-1]}" -def emoji_replace(match: re.Match[str], strength: float = 0.0) -> str: - """Replace a punctuation character with an emoticon.""" - match_string = match.group() - if random.random() < strength: - return f" {random.choice(EMOJIS)} " - return match_string +def emoji_string(_text: str) -> str: + """Return a random emoji.""" + return f" {random.choice(EMOJIS)} " -def emoji(text: str, strength: float) -> str: - """Replace some punctuation with emoticons.""" - return REGEX_PUNCTUATION.sub(partial(emoji_replace, strength=strength), text, 0) - - -def tildes(match: re.Match[str], strength: float = 0.0) -> str: - """Add some tildes to spaces.""" - match_string = match.group() - if random.random() < strength: - return "~" - return match_string +def re_sub( + text: str, + match_pattern: re.Pattern[str], + replace_pattern: str, +) -> str: + """Replace pattern in string.""" + return match_pattern.sub(replace_pattern, text) -def tildify(text: str, strength: float) -> str: - """Add some tildes to spaces.""" - return REGEX_TILDE.sub(partial(tildes, strength=strength), text, 0) +def re_sub_maybe( + text: str, + pattern: re.Pattern[str], + text_getter: Callable[[str], str], + strength: float = 0.0, +) -> str: + """Replace pattern in string randomly.""" + matches = pattern.findall(text) + for match in matches: + new_text = match.group() + if random.random() < strength: + new_text = text_getter(new_text) + text = text.replace(match, new_text) + return text def uwuify( @@ -141,7 +130,7 @@ def uwuify( tilde_strength: float = 0.1, minimun_processable_length: int = 2, ) -> str: - """Take a string and returns an uwuified version of it.""" + """Uwuify a string.""" contains_alpha = any(char.isalpha() for char in text) if len(text) < minimun_processable_length and not contains_alpha: @@ -152,14 +141,14 @@ def uwuify( transforms = [ word_replace, - nyaify, - char_replace, - partial(stutter, strength=stutter_strength), - partial(emoji, strength=emoji_strength), - partial(tildify, strength=tilde_strength), + partial(re_sub, match_pattern=REGEX_NYA, replace_pattern=SUBSTITUTE_NYA), + partial(re_sub, match_pattern=REGEX_WORD_REPLACE, replace_pattern="w"), + partial(re_sub_maybe, pattern=REGEX_TILDE, text_getter=stutter_string, strength=stutter_strength), + partial(re_sub_maybe, pattern=REGEX_PUNCTUATION, text_getter=emoji_string, strength=emoji_strength), + partial(re_sub_maybe, pattern=REGEX_TILDE, text_getter=lambda _text: "~", strength=tilde_strength), ] for transform in transforms: - text = transform(text) + text = transform(text) # type: ignore[operator] if text == original_text and contains_alpha: return uwuify( From 324c61b6528e73af0e8e042d3dfab2423677013b Mon Sep 17 00:00:00 2001 From: Bradley Reynolds Date: Sun, 24 Mar 2024 06:12:42 +0000 Subject: [PATCH 5/8] Move uwuifier into submodule Signed-off-by: GitHub --- src/imsosorry/uwuification/__init__.py | 7 ++ src/imsosorry/uwuification/constants.py | 69 ++++++++++++++++ .../uwuifier.py} | 81 +++---------------- 3 files changed, 88 insertions(+), 69 deletions(-) create mode 100644 src/imsosorry/uwuification/__init__.py create mode 100644 src/imsosorry/uwuification/constants.py rename src/imsosorry/{uwuification.py => uwuification/uwuifier.py} (59%) diff --git a/src/imsosorry/uwuification/__init__.py b/src/imsosorry/uwuification/__init__.py new file mode 100644 index 0000000..abe5fc3 --- /dev/null +++ b/src/imsosorry/uwuification/__init__.py @@ -0,0 +1,7 @@ +"""UwU-ification of text.""" + +from .uwuifier import uwuify + +__all__ = [ + "uwuify", +] diff --git a/src/imsosorry/uwuification/constants.py b/src/imsosorry/uwuification/constants.py new file mode 100644 index 0000000..20a1d12 --- /dev/null +++ b/src/imsosorry/uwuification/constants.py @@ -0,0 +1,69 @@ +"""Regex and map constants for uwuification.""" + +import re + +REGEX_WORD_REPLACE = re.compile(r"(?w<", + "(⑅˘꒳˘)", + "(ꈍᴗꈍ)", + "(˘ω˘)", + "(U ᵕ U❁)", + "σωσ", + "òωó", + "(///ˬ///✿)", + "(U ﹏ U)", # noqa: RUF001 - literally the point... + "( ͡o ω ͡o )", + "ʘwʘ", + ":3", + ":3", # important enough to have twice + "XD", + "nyaa~~", + "mya", + ">_<", + "😳", + "🥺", + "😳😳😳", + "rawr", + "^^", + "^^;;", + "(ˆ ﻌ ˆ)♡", # noqa: RUF001 - literally the point... + "^•ﻌ•^", + "/(^•ω•^)", + "(✿oωo)", +] +"""A list of emojis/emoticons to add.""" diff --git a/src/imsosorry/uwuification.py b/src/imsosorry/uwuification/uwuifier.py similarity index 59% rename from src/imsosorry/uwuification.py rename to src/imsosorry/uwuification/uwuifier.py index 0413201..156e1f3 100644 --- a/src/imsosorry/uwuification.py +++ b/src/imsosorry/uwuification/uwuifier.py @@ -3,81 +3,24 @@ from __future__ import annotations import random -import re from copy import copy from functools import partial from typing import TYPE_CHECKING if TYPE_CHECKING: + import re from collections.abc import Callable -WORD_REPLACE = { - "small": "smol", - "cute": "kawaii~", - "fluff": "floof", - "love": "luv", - "stupid": "baka", - "idiot": "baka", - "what": "nani", - "meow": "nya~", - "roar": "rawrr~", -} -"""A dict to match certain words for replacement words""" - -EMOJIS = [ - "rawr x3", - "OwO", - "UwU", - "o.O", - "-.-", - ">w<", - "(⑅˘꒳˘)", - "(ꈍᴗꈍ)", - "(˘ω˘)", - "(U ᵕ U❁)", - "σωσ", - "òωó", - "(///ˬ///✿)", - "(U ﹏ U)", # noqa: RUF001 - literally the point... - "( ͡o ω ͡o )", - "ʘwʘ", - ":3", - ":3", # important enough to have twice - "XD", - "nyaa~~", - "mya", - ">_<", - "😳", - "🥺", - "😳😳😳", - "rawr", - "^^", - "^^;;", - "(ˆ ﻌ ˆ)♡", # noqa: RUF001 - literally the point... - "^•ﻌ•^", - "/(^•ω•^)", - "(✿oωo)", -] -"""A list of emojis/emoticons to add.""" - -REGEX_WORD_REPLACE = re.compile(r"(?\g<2>-\g<2>" -"""A regex to add st-stuttering to strings.""" - -REGEX_NYA = re.compile(r"n([aeou][^aeiou])") -"""A regex to detect words with an n before a vowel to nyaify.""" -SUBSTITUTE_NYA = r"ny\1" -"""A regex to to nyaify words.""" +from .constants import ( + EMOJIS, + REGEX_NYA, + REGEX_PUNCTUATION, + REGEX_STUTTER, + REGEX_TILDE, + REGEX_WORD_REPLACE, + SUBSTITUTE_NYA, + WORD_REPLACE, +) def word_replace(text: str) -> str: @@ -143,7 +86,7 @@ def uwuify( word_replace, partial(re_sub, match_pattern=REGEX_NYA, replace_pattern=SUBSTITUTE_NYA), partial(re_sub, match_pattern=REGEX_WORD_REPLACE, replace_pattern="w"), - partial(re_sub_maybe, pattern=REGEX_TILDE, text_getter=stutter_string, strength=stutter_strength), + partial(re_sub_maybe, pattern=REGEX_STUTTER, text_getter=stutter_string, strength=stutter_strength), partial(re_sub_maybe, pattern=REGEX_PUNCTUATION, text_getter=emoji_string, strength=emoji_strength), partial(re_sub_maybe, pattern=REGEX_TILDE, text_getter=lambda _text: "~", strength=tilde_strength), ] From 666ec919d2d2b553546d97174a4004c440a788c4 Mon Sep 17 00:00:00 2001 From: Bradley Reynolds Date: Sun, 24 Mar 2024 06:15:19 +0000 Subject: [PATCH 6/8] Move TYPE_CHECKING block below imports Signed-off-by: GitHub --- src/imsosorry/uwuification/uwuifier.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/imsosorry/uwuification/uwuifier.py b/src/imsosorry/uwuification/uwuifier.py index 156e1f3..e03e3ea 100644 --- a/src/imsosorry/uwuification/uwuifier.py +++ b/src/imsosorry/uwuification/uwuifier.py @@ -7,10 +7,6 @@ from functools import partial from typing import TYPE_CHECKING -if TYPE_CHECKING: - import re - from collections.abc import Callable - from .constants import ( EMOJIS, REGEX_NYA, @@ -22,6 +18,10 @@ WORD_REPLACE, ) +if TYPE_CHECKING: + import re + from collections.abc import Callable + def word_replace(text: str) -> str: """Replace words that are keys in the word replacement hash to the values specified.""" From 75ecb60f8eaf101901451207583a68bf70024fe7 Mon Sep 17 00:00:00 2001 From: Bradley Reynolds Date: Sun, 24 Mar 2024 07:13:49 +0000 Subject: [PATCH 7/8] Use functions instead of partials Signed-off-by: GitHub --- .../uwuification/replacers/__init__.py | 1 + src/imsosorry/uwuification/replacers/regex.py | 38 ++++++++++ src/imsosorry/uwuification/uwuifier.py | 72 +++++++++---------- tests/test_uwuification.py | 6 +- 4 files changed, 77 insertions(+), 40 deletions(-) create mode 100644 src/imsosorry/uwuification/replacers/__init__.py create mode 100644 src/imsosorry/uwuification/replacers/regex.py diff --git a/src/imsosorry/uwuification/replacers/__init__.py b/src/imsosorry/uwuification/replacers/__init__.py new file mode 100644 index 0000000..d53b088 --- /dev/null +++ b/src/imsosorry/uwuification/replacers/__init__.py @@ -0,0 +1 @@ +"""Replacers.""" diff --git a/src/imsosorry/uwuification/replacers/regex.py b/src/imsosorry/uwuification/replacers/regex.py new file mode 100644 index 0000000..f65a17f --- /dev/null +++ b/src/imsosorry/uwuification/replacers/regex.py @@ -0,0 +1,38 @@ +"""Regex replacers.""" + +from __future__ import annotations + +import random +from functools import partial +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + import re + from collections.abc import Callable + + +def re_sub( + text: str, + match_pattern: re.Pattern[str], + replace_pattern: str, +) -> str: + """Replace pattern in string.""" + return match_pattern.sub(replace_pattern, text) + + +def re_sub_maybe( + text: str, + pattern: re.Pattern[str], + text_getter: Callable[[str], str], + strength: float = 0.0, +) -> str: + """Replace pattern in string randomly.""" + + def inner(match: re.Match[str], strength: float) -> str: + """Replace text randomly.""" + match_string = match.group() + if random.random() < strength: + return text_getter(match_string) + return match_string + + return pattern.sub(partial(inner, strength=strength), text) diff --git a/src/imsosorry/uwuification/uwuifier.py b/src/imsosorry/uwuification/uwuifier.py index e03e3ea..9a372c6 100644 --- a/src/imsosorry/uwuification/uwuifier.py +++ b/src/imsosorry/uwuification/uwuifier.py @@ -1,11 +1,12 @@ -"""The ancient arts of Uwuification.""" +"""Uwuification of text.""" from __future__ import annotations import random from copy import copy from functools import partial -from typing import TYPE_CHECKING + +from imsosorry.uwuification.replacers.regex import re_sub, re_sub_maybe from .constants import ( EMOJIS, @@ -18,9 +19,15 @@ WORD_REPLACE, ) -if TYPE_CHECKING: - import re - from collections.abc import Callable + +def stutter_string(text: str) -> str: + """Repeat the last character in a string.""" + return f"{text}-{text[-1]}" + + +def emoji_string(_text: str) -> str: + """Return a random emoji.""" + return f" {random.choice(EMOJIS)} " def word_replace(text: str) -> str: @@ -30,39 +37,29 @@ def word_replace(text: str) -> str: return text -def stutter_string(text: str) -> str: - """Repeat the last character in a string.""" - return f"{text}-{text[-1]}" +def nyaify(text: str) -> str: + """Nyaify a string by adding a 'y' between an 'n' and a vowel.""" + return re_sub(text=text, match_pattern=REGEX_NYA, replace_pattern=SUBSTITUTE_NYA) -def emoji_string(_text: str) -> str: - """Return a random emoji.""" - return f" {random.choice(EMOJIS)} " +def char_replace(text: str) -> str: + """Replace certain characters with 'w'.""" + return re_sub(text=text, match_pattern=REGEX_WORD_REPLACE, replace_pattern="w") -def re_sub( - text: str, - match_pattern: re.Pattern[str], - replace_pattern: str, -) -> str: - """Replace pattern in string.""" - return match_pattern.sub(replace_pattern, text) +def stutter(text: str, strength: float) -> str: + """Add stuttering to a string.""" + return re_sub_maybe(text=text, pattern=REGEX_STUTTER, text_getter=stutter_string, strength=strength) -def re_sub_maybe( - text: str, - pattern: re.Pattern[str], - text_getter: Callable[[str], str], - strength: float = 0.0, -) -> str: - """Replace pattern in string randomly.""" - matches = pattern.findall(text) - for match in matches: - new_text = match.group() - if random.random() < strength: - new_text = text_getter(new_text) - text = text.replace(match, new_text) - return text +def emoji(text: str, strength: float) -> str: + """Replace some punctuation with emoticons.""" + return re_sub_maybe(text=text, pattern=REGEX_PUNCTUATION, text_getter=emoji_string, strength=strength) + + +def tildify(text: str, strength: float) -> str: + """Add some tildes to spaces.""" + return re_sub_maybe(text=text, pattern=REGEX_TILDE, text_getter=lambda _text: "~", strength=strength) def uwuify( @@ -84,11 +81,12 @@ def uwuify( transforms = [ word_replace, - partial(re_sub, match_pattern=REGEX_NYA, replace_pattern=SUBSTITUTE_NYA), - partial(re_sub, match_pattern=REGEX_WORD_REPLACE, replace_pattern="w"), - partial(re_sub_maybe, pattern=REGEX_STUTTER, text_getter=stutter_string, strength=stutter_strength), - partial(re_sub_maybe, pattern=REGEX_PUNCTUATION, text_getter=emoji_string, strength=emoji_strength), - partial(re_sub_maybe, pattern=REGEX_TILDE, text_getter=lambda _text: "~", strength=tilde_strength), + nyaify, + char_replace, + stutter, + partial(stutter, strength=stutter_strength), + partial(emoji, strength=emoji_strength), + partial(tildify, strength=tilde_strength), ] for transform in transforms: text = transform(text) # type: ignore[operator] diff --git a/tests/test_uwuification.py b/tests/test_uwuification.py index ebc5212..572beab 100644 --- a/tests/test_uwuification.py +++ b/tests/test_uwuification.py @@ -1,11 +1,11 @@ -"""Test the arts of Uwuification.""" +"""Test the uwuification.""" from __future__ import annotations import pytest -from imsosorry.uwuification import ( - EMOJIS, +from imsosorry.uwuification.constants import EMOJIS +from imsosorry.uwuification.uwuifier import ( char_replace, emoji, nyaify, From 94d325f7c4b18cff6ecc91e050502a0e1080f428 Mon Sep 17 00:00:00 2001 From: Bradley Reynolds Date: Sun, 24 Mar 2024 07:26:10 +0000 Subject: [PATCH 8/8] Drop re_sub Signed-off-by: GitHub --- src/imsosorry/uwuification/replacers/regex.py | 9 -------- src/imsosorry/uwuification/uwuifier.py | 21 ++++++++++++------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/imsosorry/uwuification/replacers/regex.py b/src/imsosorry/uwuification/replacers/regex.py index f65a17f..faa746f 100644 --- a/src/imsosorry/uwuification/replacers/regex.py +++ b/src/imsosorry/uwuification/replacers/regex.py @@ -11,15 +11,6 @@ from collections.abc import Callable -def re_sub( - text: str, - match_pattern: re.Pattern[str], - replace_pattern: str, -) -> str: - """Replace pattern in string.""" - return match_pattern.sub(replace_pattern, text) - - def re_sub_maybe( text: str, pattern: re.Pattern[str], diff --git a/src/imsosorry/uwuification/uwuifier.py b/src/imsosorry/uwuification/uwuifier.py index 9a372c6..42d1af6 100644 --- a/src/imsosorry/uwuification/uwuifier.py +++ b/src/imsosorry/uwuification/uwuifier.py @@ -6,7 +6,7 @@ from copy import copy from functools import partial -from imsosorry.uwuification.replacers.regex import re_sub, re_sub_maybe +from imsosorry.uwuification.replacers.regex import re_sub_maybe from .constants import ( EMOJIS, @@ -20,16 +20,21 @@ ) -def stutter_string(text: str) -> str: +def _stutter_string(text: str) -> str: """Repeat the last character in a string.""" return f"{text}-{text[-1]}" -def emoji_string(_text: str) -> str: +def _emoji_string(_text: str) -> str: """Return a random emoji.""" return f" {random.choice(EMOJIS)} " +def _tildify_string(_text: str) -> str: + """Repeat the last character in a string.""" + return "~" + + def word_replace(text: str) -> str: """Replace words that are keys in the word replacement hash to the values specified.""" for word, replacement in WORD_REPLACE.items(): @@ -39,27 +44,27 @@ def word_replace(text: str) -> str: def nyaify(text: str) -> str: """Nyaify a string by adding a 'y' between an 'n' and a vowel.""" - return re_sub(text=text, match_pattern=REGEX_NYA, replace_pattern=SUBSTITUTE_NYA) + return REGEX_NYA.sub(SUBSTITUTE_NYA, text) def char_replace(text: str) -> str: """Replace certain characters with 'w'.""" - return re_sub(text=text, match_pattern=REGEX_WORD_REPLACE, replace_pattern="w") + return REGEX_WORD_REPLACE.sub("w", text) def stutter(text: str, strength: float) -> str: """Add stuttering to a string.""" - return re_sub_maybe(text=text, pattern=REGEX_STUTTER, text_getter=stutter_string, strength=strength) + return re_sub_maybe(text=text, pattern=REGEX_STUTTER, text_getter=_stutter_string, strength=strength) def emoji(text: str, strength: float) -> str: """Replace some punctuation with emoticons.""" - return re_sub_maybe(text=text, pattern=REGEX_PUNCTUATION, text_getter=emoji_string, strength=strength) + return re_sub_maybe(text=text, pattern=REGEX_PUNCTUATION, text_getter=_emoji_string, strength=strength) def tildify(text: str, strength: float) -> str: """Add some tildes to spaces.""" - return re_sub_maybe(text=text, pattern=REGEX_TILDE, text_getter=lambda _text: "~", strength=strength) + return re_sub_maybe(text=text, pattern=REGEX_TILDE, text_getter=_tildify_string, strength=strength) def uwuify(