Skip to content

Commit

Permalink
fix: remove redundant modern_ prefix
Browse files Browse the repository at this point in the history
Who cares about archaic letters anyway.
  • Loading branch information
WieeRd committed Feb 17, 2024
1 parent 3590398 commit 2b9b401
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions ricecake/hangul/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def compose(cho: str, jung: str, jong: str | None) -> str:
ValueError: If the characters are not appropriate Hangul Jamos.
"""
return chr(
o.modern_choseong_offset(cho) * o.CHOSEONG_COEF
+ o.modern_jongseong_offset(jung) * o.JUNGSEONG_COEF
+ (o.modern_jongseong_offset(jong) if jong else 0)
o.choseong_offset(cho) * o.CHOSEONG_COEF
+ o.jongseong_offset(jung) * o.JUNGSEONG_COEF
+ (o.jongseong_offset(jong) if jong else 0)
+ o.SYLLABLE_BASE
)

Expand Down
16 changes: 8 additions & 8 deletions ricecake/hangul/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)

__all__ = [
"modern_jamo_to_compat_jamo",
"jamo_to_compat_jamo",
"compat_jaum_to_choseong",
"compat_moum_to_jungseong",
"compat_jaum_to_jongseong",
Expand All @@ -23,22 +23,22 @@
# | - [ ] add `classify_jamo() -> tuple[JamoKind, int]`
# | - [ ] `jamo_to_compat_jamo() -> str | None`
# | - [x] RIIR & PyO3
def modern_jamo_to_compat_jamo(c: str, /) -> str:
def jamo_to_compat_jamo(c: str, /) -> str:
"""Converts a Hangul Jamo character to a Compatibility Jamo character.
Raises:
ValueError: If the character is not a Hangul Jamo.
"""
with suppress(ValueError):
i = offset.modern_choseong_offset(c)
i = offset.choseong_offset(c)
return CHOSEONG_TO_COMPAT_JAUM[i]

with suppress(ValueError):
i = offset.modern_jungseong_offset(c)
i = offset.jungseong_offset(c)
return chr(i + offset.MODERN_COMPAT_MOUM_BASE)

with suppress(ValueError):
i = offset.modern_jongseong_offset(c)
i = offset.jongseong_offset(c)
return JONGSEONG_TO_COMPAT_JAUM[i - 1]

raise ValueError("expected a modern Hangul Jamo character")
Expand All @@ -52,7 +52,7 @@ def compat_jaum_to_choseong(c: str, /) -> str | None:
Raises:
ValueError: If the character is not a Hangul Compatibility Jamo Jaum.
"""
i = offset.modern_compat_jaum_offset(c)
i = offset.compat_jaum_offset(c)
return COMPAT_JAUM_TO_CHOSEONG[i]


Expand All @@ -62,7 +62,7 @@ def compat_moum_to_jungseong(c: str, /) -> str:
Raises:
ValueError: If the character is not a Hangul Compatibility Jamo Moum.
"""
i = offset.modern_compat_moum_offset(c)
i = offset.compat_moum_offset(c)
return chr(i + offset.MODERN_JUNGSEONG_BASE)


Expand All @@ -72,5 +72,5 @@ def compat_jaum_to_jongseong(c: str, /) -> str:
Raises:
ValueError: If the character is not a Hangul Compatibility Jamo Jaum.
"""
i = offset.modern_compat_jaum_offset(c)
i = offset.compat_jaum_offset(c)
return COMPAT_JAUM_TO_JONGSEONG[i]
10 changes: 5 additions & 5 deletions ricecake/hangul/offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def jamo_offset(c: str, /) -> int:
raise ValueError("expected a Hangul Jamo character")


def modern_choseong_offset(c: str, /) -> int:
def choseong_offset(c: str, /) -> int:
"""Calculates the Choseong offset of a modern Hangul Jamo character.
Raises:
Expand All @@ -152,7 +152,7 @@ def modern_choseong_offset(c: str, /) -> int:
raise ValueError("expected a modern Hangul Jamo Choseong character")


def modern_jungseong_offset(c: str, /) -> int:
def jungseong_offset(c: str, /) -> int:
"""Calculates the Jungseong offset of a modern Hangul Jamo character.
Raises:
Expand All @@ -164,7 +164,7 @@ def modern_jungseong_offset(c: str, /) -> int:
raise ValueError("expected a modern Hangul Jamo Jungseong character")


def modern_jongseong_offset(c: str, /) -> int:
def jongseong_offset(c: str, /) -> int:
"""Calculates the Jungseong offset of a modern Hangul Jamo character.
Note that unlike Choseong and Jungseong, Jongseong offset starts from 1.
Expand Down Expand Up @@ -193,7 +193,7 @@ def compat_jamo_offset(c: str, /) -> int:
raise ValueError("expected a Hangul Compatibility Jamo character")


def modern_compat_jaum_offset(c: str, /) -> int:
def compat_jaum_offset(c: str, /) -> int:
"""Calculates the Jaum offset of a modern Hangul Compatibility Jamo character.
Raises:
Expand All @@ -205,7 +205,7 @@ def modern_compat_jaum_offset(c: str, /) -> int:
raise ValueError("expected a modern Hangul Compatibility Jamo Jaum character")


def modern_compat_moum_offset(c: str, /) -> int:
def compat_moum_offset(c: str, /) -> int:
"""Calculates the Moum offset of a modern Hangul Compatibility Jamo character.
Raises:
Expand Down

0 comments on commit 2b9b401

Please sign in to comment.