Skip to content

Commit

Permalink
Update to 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
deadshot465 committed Dec 3, 2023
1 parent f0051fb commit aa2eea2
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.1.0
**This version changed some mappings in presets, so the same input probably won't return the same result as version 2.0.0.**

- Add more word mappings, so it's on par with mohan-cao's latest owoify.
- Add uwuify and uvuify for convenience.

## 2.0.1
Bump to 2.0.1

Expand Down
19 changes: 18 additions & 1 deletion owoify/owoify.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from owoify.structures.word import Word
import re


WORD_REGEX = re.compile(r'[^\s]+')
SPACE_REGEX = re.compile(r'\s+')

Expand Down Expand Up @@ -70,3 +69,21 @@ def owoify(source: str, level: Owoness = Owoness.Owo) -> str:
result = interleave_arrays(words, spaces)
result_strings = list(map(lambda w: str(w), result))
return ''.join(result_strings)


def uwuify(source: str) -> str:
"""
Owoify the source string using Uwu owoness.
:param source: The source string to owoify.
:return: The owoified string.
"""
return owoify(source, Owoness.Uwu)


def uvuify(source: str) -> str:
"""
Owoify the source string using Uvu owoness.
:param source: The source string to owoify.
:return: The owoified string.
"""
return owoify(source, Owoness.Uvu)
64 changes: 60 additions & 4 deletions owoify/utility/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@
LY_TO_WY_LOWER = re.compile(r'ly')
PLE_TO_PWE = re.compile(r'([Pp])le')
NR_TO_NW_UPPER = re.compile(r'NR')
NR_TO_NW_LOWER = re.compile(r'nr')
NR_TO_NW_LOWER = re.compile(r'([Nn])r')
MEM_TO_MWEM_UPPER = re.compile(r'Mem')
MEM_TO_MWEM_LOWER = re.compile(r'mem')
NYWO_TO_NYO = re.compile(r'([Nn])ywo')
FUC_TO_FWUC = re.compile(r'([Ff])uc')
MOM_TO_MWOM = re.compile(r'([Mm])om')
ME_TO_MWE = re.compile(r'([Mm])e')
ME_TO_MWE_UPPER = re.compile(r'^Me$')
ME_TO_MWE_LOWER = re.compile(r'^me$')
N_VOWEL_TO_NY_FIRST = re.compile(r'n([aeiou])')
N_VOWEL_TO_NY_SECOND = re.compile(r'N([aeiou])')
N_VOWEL_TO_NY_THIRD = re.compile(r'N([AEIOU])')
Expand All @@ -62,6 +66,15 @@
TIME_TO_TIM = re.compile(r'\b([Tt])ime\b')
OVER_TO_OWOR = re.compile(r'([Oo])ver')
WORSE_TO_WOSE = re.compile(r'([Ww])orse')
GREAT_TO_GWATE = re.compile(r'([Gg])reat')
AVIAT_TO_AWIAT = re.compile(r'([Aa])viat')
DEDICAT_TO_DEDITAT = re.compile(r'([Dd])edicat')
REMEMBER_TO_REMBER = re.compile(r'([Rr])emember')
WHEN_TO_WEN = re.compile(r'([Ww])hen')
FRIGHTENED_TO_FRIGTEN = re.compile(r'([Ff])righten(ed)*')
MEME_TO_MEM_FIRST = re.compile(r'Meme')
MEME_TO_MEM_SECOND = re.compile(r'Mem')
FEEL_TO_FELL = re.compile(r'^([Ff])eel$')

# Additional kaomojis come from [owoify](https://pypi.org/project/owoify/) and Discord.
FACES = [
Expand Down Expand Up @@ -218,10 +231,19 @@ def map_ple_to_pwe(input: Word) -> Word:


def map_nr_to_nw(input: Word) -> Word:
return input.replace(NR_TO_NW_LOWER, 'nw') \
return input.replace(NR_TO_NW_LOWER, '\\1w') \
.replace(NR_TO_NW_UPPER, 'NW')


def map_mem_to_mwem(input: Word) -> Word:
return input.replace(MEM_TO_MWEM_UPPER, 'mwem') \
.replace(MEM_TO_MWEM_LOWER, 'Mwem')


def unmap_nywo_to_nyo(input: Word) -> Word:
return input.replace(NYWO_TO_NYO, '\\1yo')


def map_fuc_to_fwuc(input: Word) -> Word:
return input.replace(FUC_TO_FWUC, '\\1wuc')

Expand All @@ -231,7 +253,8 @@ def map_mom_to_mwom(input: Word) -> Word:


def map_me_to_mwe(input: Word) -> Word:
return input.replace(ME_TO_MWE, '\\1we')
return input.replace(ME_TO_MWE_UPPER, 'Mwe') \
.replace(ME_TO_MWE_LOWER, 'mwe')


def map_n_vowel_to_ny(input: Word) -> Word:
Expand Down Expand Up @@ -268,3 +291,36 @@ def map_over_to_owor(input: Word) -> Word:

def map_worse_to_wose(input: Word) -> Word:
return input.replace(WORSE_TO_WOSE, '\\1ose')


def map_great_to_gwate(input: Word) -> Word:
return input.replace(GREAT_TO_GWATE, '\\1wate')


def map_aviat_to_awiat(input: Word) -> Word:
return input.replace(AVIAT_TO_AWIAT, '\\1wiat')


def map_dedicat_to_deditat(input: Word) -> Word:
return input.replace(DEDICAT_TO_DEDITAT, '\\1editat')


def map_remember_to_rember(input: Word) -> Word:
return input.replace(REMEMBER_TO_REMBER, '\\1ember')


def map_when_to_wen(input: Word) -> Word:
return input.replace(WHEN_TO_WEN, '\\1en')


def map_frightened_to_frigten(input: Word) -> Word:
return input.replace(FRIGHTENED_TO_FRIGTEN, '\\1rigten')


def map_meme_to_mem(input: Word) -> Word:
return input.replace(MEME_TO_MEM_FIRST, 'mem') \
.replace(MEME_TO_MEM_SECOND, 'Mem')


def map_feel_to_fell(input: Word) -> Word:
return input.replace(FEEL_TO_FELL, '\\1ell')
13 changes: 8 additions & 5 deletions owoify/utility/presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

SPECIFIC_WORD_MAPPING_LIST = [
map_fuc_to_fwuc, map_mom_to_mwom, map_time_to_tim, map_me_to_mwe,
map_n_vowel_to_ny, map_over_to_owor, map_ove_to_uv, map_haha_to_hehe_xd,
map_the_to_teh, map_you_to_u, map_read_to_wead, map_worse_to_wose
map_over_to_owor, map_ove_to_uv, map_haha_to_hehe_xd,
map_the_to_teh, map_you_to_u, map_read_to_wead, map_worse_to_wose,
map_great_to_gwate, map_aviat_to_awiat, map_dedicat_to_deditat,
map_remember_to_rember, map_when_to_wen, map_frightened_to_frigten,
map_meme_to_mem, map_feel_to_fell
]

UVU_MAPPING_LIST = [
Expand All @@ -19,9 +22,9 @@
]

OWO_MAPPING_LIST = [
map_ll_to_ww, map_vowel_or_r_except_o_l_to_wl, map_old_to_owld,
map_n_vowel_to_ny, map_ll_to_ww, map_vowel_or_r_except_o_l_to_wl, map_old_to_owld,
map_ol_to_owl, map_l_or_r_o_to_wo, map_specific_consonants_o_to_letter_and_wo,
map_v_or_w_le_to_wal, map_fi_to_fwi, map_ver_to_wer, map_poi_to_pwoi,
map_specific_consonants_le_to_letter_and_wal, map_consonant_r_to_consonant_w,
map_ly_to_wy, map_ple_to_pwe, map_nr_to_nw
]
map_ly_to_wy, map_ple_to_pwe, map_nr_to_nw, map_mem_to_mwem, unmap_nywo_to_nyo
]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='owoify-py',
version='2.0.1',
version='2.1.0',
author='Chehui Chou',
author_email='[email protected]',
description='Turning your worst nightmare into a Python package.',
Expand Down

0 comments on commit aa2eea2

Please sign in to comment.