koreanwritingsystem 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- koreanwritingsystem-1.0.0/LICENSE +9 -0
- koreanwritingsystem-1.0.0/PKG-INFO +41 -0
- koreanwritingsystem-1.0.0/README.md +27 -0
- koreanwritingsystem-1.0.0/koreanwritingsystem/__init__.py +82 -0
- koreanwritingsystem-1.0.0/koreanwritingsystem.egg-info/PKG-INFO +41 -0
- koreanwritingsystem-1.0.0/koreanwritingsystem.egg-info/SOURCES.txt +8 -0
- koreanwritingsystem-1.0.0/koreanwritingsystem.egg-info/dependency_links.txt +1 -0
- koreanwritingsystem-1.0.0/koreanwritingsystem.egg-info/top_level.txt +1 -0
- koreanwritingsystem-1.0.0/pyproject.toml +28 -0
- koreanwritingsystem-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Korean Writing System — CC0 1.0 Universal
|
|
2
|
+
|
|
3
|
+
This software is released under the Creative Commons Zero v1.0 Universal (CC0 1.0) license.
|
|
4
|
+
|
|
5
|
+
To the extent possible under law, the author has waived all copyright and related or neighboring rights to this work.
|
|
6
|
+
You may copy, modify, distribute, and use this software for any purpose, including commercial purposes, without asking permission.
|
|
7
|
+
|
|
8
|
+
Full legal text:
|
|
9
|
+
https://creativecommons.org/publicdomain/zero/1.0/
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: koreanwritingsystem
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Decompose Hangul into Jamo. Compose Jamo into Hangul or compose Jamo indexes into Hangul.
|
|
5
|
+
Author: Nagao Yuji
|
|
6
|
+
License: CC0-1.0
|
|
7
|
+
Project-URL: homepage, https://github.com/DukaCrazy/koreanwritingsystem
|
|
8
|
+
Project-URL: repository, https://github.com/DukaCrazy/koreanwritingsystem
|
|
9
|
+
Keywords: hangul,korean,jamo,compose hangul,decompose jamo
|
|
10
|
+
Requires-Python: >=3.0
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# Korean Writing System
|
|
16
|
+
The modern Korean writing system is remarkably logical, consistent, and well‑designed.
|
|
17
|
+
This module implements the fundamental structure of Hangul: decomposing syllables into jamo and composing jamo back into syllables.
|
|
18
|
+
|
|
19
|
+
Special thanks to **Joe Becker, Lee Collins, Mark Davis, and the teams** who created and maintain Unicode.
|
|
20
|
+
|
|
21
|
+
Developed by **N. Y**.
|
|
22
|
+
This code was created with support from **Microsoft Copilot**.
|
|
23
|
+
Reviewed by **N. Y**.
|
|
24
|
+
|
|
25
|
+
Compatible with Python **≥ 3.0**
|
|
26
|
+
Distributed under the **CC0‑1.0** license
|
|
27
|
+
|
|
28
|
+
Main functions:
|
|
29
|
+
|
|
30
|
+
Decompose Hangul into Jamo
|
|
31
|
+
Compose Jamo into Hangul
|
|
32
|
+
Compose Jamo indexes into Hangul
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
# In: Hangul >>> Out: [CHOSEONG, JUNGSEONG, JONGSEONG]
|
|
36
|
+
print(KoreanWritingSystem.decompose_hangul_to_jamo('가'))
|
|
37
|
+
#In: [CHOSEONG, JUNGSEONG, JONGSEONG] >>> Out: Hangul
|
|
38
|
+
print(KoreanWritingSystem.compose_hangul_with_jamo('ㄱ','ㅏ',''))
|
|
39
|
+
#In: [i, j, k] >>> Out: Hangul
|
|
40
|
+
print(KoreanWritingSystem.compose_hangul_with_number(0,0,0))
|
|
41
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Korean Writing System
|
|
2
|
+
The modern Korean writing system is remarkably logical, consistent, and well‑designed.
|
|
3
|
+
This module implements the fundamental structure of Hangul: decomposing syllables into jamo and composing jamo back into syllables.
|
|
4
|
+
|
|
5
|
+
Special thanks to **Joe Becker, Lee Collins, Mark Davis, and the teams** who created and maintain Unicode.
|
|
6
|
+
|
|
7
|
+
Developed by **N. Y**.
|
|
8
|
+
This code was created with support from **Microsoft Copilot**.
|
|
9
|
+
Reviewed by **N. Y**.
|
|
10
|
+
|
|
11
|
+
Compatible with Python **≥ 3.0**
|
|
12
|
+
Distributed under the **CC0‑1.0** license
|
|
13
|
+
|
|
14
|
+
Main functions:
|
|
15
|
+
|
|
16
|
+
Decompose Hangul into Jamo
|
|
17
|
+
Compose Jamo into Hangul
|
|
18
|
+
Compose Jamo indexes into Hangul
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
# In: Hangul >>> Out: [CHOSEONG, JUNGSEONG, JONGSEONG]
|
|
22
|
+
print(KoreanWritingSystem.decompose_hangul_to_jamo('가'))
|
|
23
|
+
#In: [CHOSEONG, JUNGSEONG, JONGSEONG] >>> Out: Hangul
|
|
24
|
+
print(KoreanWritingSystem.compose_hangul_with_jamo('ㄱ','ㅏ',''))
|
|
25
|
+
#In: [i, j, k] >>> Out: Hangul
|
|
26
|
+
print(KoreanWritingSystem.compose_hangul_with_number(0,0,0))
|
|
27
|
+
```
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# ---------------------------------------------------------
|
|
2
|
+
#Tuple
|
|
3
|
+
# CHOSEONG -> 0-18 -> LEADING_CONSONANT
|
|
4
|
+
# JUNGSEONG -> 0-20 -> VOWEL
|
|
5
|
+
# JONGSEONG -> 0-27 -> TRAILING_CONSONANT
|
|
6
|
+
|
|
7
|
+
# JAMO = CHOSEONG, JUNGSEONG and JONGSEONG
|
|
8
|
+
|
|
9
|
+
# ---------------------------------------------------------
|
|
10
|
+
class KoreanWritingSystem:
|
|
11
|
+
# LEADING_CONSONANT
|
|
12
|
+
CHOSEONG = (
|
|
13
|
+
"ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ",
|
|
14
|
+
"ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"
|
|
15
|
+
)
|
|
16
|
+
# VOWEL
|
|
17
|
+
JUNGSEONG = (
|
|
18
|
+
"ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ",
|
|
19
|
+
"ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"
|
|
20
|
+
)
|
|
21
|
+
# TRAILING_CONSONANT
|
|
22
|
+
JONGSEONG = (
|
|
23
|
+
"", "ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ",
|
|
24
|
+
"ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ",
|
|
25
|
+
"ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
UNICODE_START_POSITION = 0xAC00
|
|
29
|
+
N_LEADING_CONSONANT = 19 # choseong
|
|
30
|
+
N_VOWEL = 21 # jungseong
|
|
31
|
+
N_TRAILING_CONSONANT = 28 # jongseong
|
|
32
|
+
|
|
33
|
+
JAMO = set(CHOSEONG) | set(JUNGSEONG) | set(JONGSEONG)
|
|
34
|
+
|
|
35
|
+
def decompose_hangul_to_jamo(hangul_or_jamo: str):
|
|
36
|
+
"""
|
|
37
|
+
Decomposes:
|
|
38
|
+
- Hangul syllables (AC00–D7A3) → (initial, vowel, final)
|
|
39
|
+
- isolated jamos (1100–11FF) → returns the jamo itself
|
|
40
|
+
- anything else → That's not an accepted character. This method only works with Hangul and Jamo.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
characters_position = ord(hangul_or_jamo)
|
|
44
|
+
|
|
45
|
+
# 1. Hangul >>> 11.172 possibilities
|
|
46
|
+
if 0xAC00 <= characters_position <= 0xD7A3:
|
|
47
|
+
S = characters_position - 0xAC00
|
|
48
|
+
lc = S // 588
|
|
49
|
+
v = (S % 588) // 28
|
|
50
|
+
tc = S % 28
|
|
51
|
+
return [KoreanWritingSystem.CHOSEONG[lc], KoreanWritingSystem.JUNGSEONG[v], KoreanWritingSystem.JONGSEONG[tc]]
|
|
52
|
+
|
|
53
|
+
# 2. Jamos >>> 78 possibilities
|
|
54
|
+
if hangul_or_jamo in KoreanWritingSystem.JAMO:
|
|
55
|
+
return [hangul_or_jamo]
|
|
56
|
+
|
|
57
|
+
# Other
|
|
58
|
+
return "That's not an accepted character. This method only works with Hangul and Jamo."
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def compose_hangul_with_number(leading_consonant: int, vowel:int, trailing_consonant:int):
|
|
62
|
+
"""
|
|
63
|
+
Recomposes a Hangul syllable using the leading_consonant, vowel, trailing_consonant indexes.
|
|
64
|
+
leading_consonant = 0–18
|
|
65
|
+
vowel = 0–20
|
|
66
|
+
trailing_consonant = 0–27
|
|
67
|
+
"""
|
|
68
|
+
codepoint = KoreanWritingSystem.UNICODE_START_POSITION + (leading_consonant * KoreanWritingSystem.N_VOWEL * KoreanWritingSystem.N_TRAILING_CONSONANT) + (vowel * KoreanWritingSystem.N_TRAILING_CONSONANT) + trailing_consonant
|
|
69
|
+
return chr(codepoint)
|
|
70
|
+
|
|
71
|
+
def compose_hangul_with_jamo(leading_consonant: str, vowel:str, trailing_consonant:str):
|
|
72
|
+
"""
|
|
73
|
+
leading_consonant >>> "ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"
|
|
74
|
+
vowel >>> "ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"
|
|
75
|
+
trailing_consonant >>> "", "ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"
|
|
76
|
+
"""
|
|
77
|
+
if leading_consonant in KoreanWritingSystem.JAMO and vowel in KoreanWritingSystem.JAMO and trailing_consonant in KoreanWritingSystem.JAMO:
|
|
78
|
+
codepoint = KoreanWritingSystem.UNICODE_START_POSITION + (KoreanWritingSystem.CHOSEONG.index(leading_consonant) * KoreanWritingSystem.N_VOWEL * KoreanWritingSystem.N_TRAILING_CONSONANT) + (KoreanWritingSystem.JUNGSEONG.index(vowel) * KoreanWritingSystem.N_TRAILING_CONSONANT) + KoreanWritingSystem.JONGSEONG.index(trailing_consonant)
|
|
79
|
+
return chr(codepoint)
|
|
80
|
+
|
|
81
|
+
# Other
|
|
82
|
+
return "That's not an accepted character. This method only works with Jamo."
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: koreanwritingsystem
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Decompose Hangul into Jamo. Compose Jamo into Hangul or compose Jamo indexes into Hangul.
|
|
5
|
+
Author: Nagao Yuji
|
|
6
|
+
License: CC0-1.0
|
|
7
|
+
Project-URL: homepage, https://github.com/DukaCrazy/koreanwritingsystem
|
|
8
|
+
Project-URL: repository, https://github.com/DukaCrazy/koreanwritingsystem
|
|
9
|
+
Keywords: hangul,korean,jamo,compose hangul,decompose jamo
|
|
10
|
+
Requires-Python: >=3.0
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# Korean Writing System
|
|
16
|
+
The modern Korean writing system is remarkably logical, consistent, and well‑designed.
|
|
17
|
+
This module implements the fundamental structure of Hangul: decomposing syllables into jamo and composing jamo back into syllables.
|
|
18
|
+
|
|
19
|
+
Special thanks to **Joe Becker, Lee Collins, Mark Davis, and the teams** who created and maintain Unicode.
|
|
20
|
+
|
|
21
|
+
Developed by **N. Y**.
|
|
22
|
+
This code was created with support from **Microsoft Copilot**.
|
|
23
|
+
Reviewed by **N. Y**.
|
|
24
|
+
|
|
25
|
+
Compatible with Python **≥ 3.0**
|
|
26
|
+
Distributed under the **CC0‑1.0** license
|
|
27
|
+
|
|
28
|
+
Main functions:
|
|
29
|
+
|
|
30
|
+
Decompose Hangul into Jamo
|
|
31
|
+
Compose Jamo into Hangul
|
|
32
|
+
Compose Jamo indexes into Hangul
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
# In: Hangul >>> Out: [CHOSEONG, JUNGSEONG, JONGSEONG]
|
|
36
|
+
print(KoreanWritingSystem.decompose_hangul_to_jamo('가'))
|
|
37
|
+
#In: [CHOSEONG, JUNGSEONG, JONGSEONG] >>> Out: Hangul
|
|
38
|
+
print(KoreanWritingSystem.compose_hangul_with_jamo('ㄱ','ㅏ',''))
|
|
39
|
+
#In: [i, j, k] >>> Out: Hangul
|
|
40
|
+
print(KoreanWritingSystem.compose_hangul_with_number(0,0,0))
|
|
41
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
koreanwritingsystem
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "koreanwritingsystem"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Decompose Hangul into Jamo. Compose Jamo into Hangul or compose Jamo indexes into Hangul."
|
|
9
|
+
authors = [
|
|
10
|
+
{ name = "Nagao Yuji" }
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
requires-python = ">=3.0"
|
|
14
|
+
|
|
15
|
+
keywords = [
|
|
16
|
+
"hangul",
|
|
17
|
+
"korean",
|
|
18
|
+
"jamo",
|
|
19
|
+
"compose hangul",
|
|
20
|
+
"decompose jamo"
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
readme = "README.md"
|
|
24
|
+
license = { text = "CC0-1.0" }
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
homepage = "https://github.com/DukaCrazy/koreanwritingsystem"
|
|
28
|
+
repository = "https://github.com/DukaCrazy/koreanwritingsystem"
|