forked from toss/es-hangul
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
584 additions
and
584 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
title: romanize | ||
--- | ||
|
||
# romanize | ||
|
||
Change the Hangul string to Roman. | ||
|
||
For detailed examples, see below. | ||
|
||
```typescript | ||
function romanize(hangul: string): string; | ||
``` | ||
|
||
## Examples | ||
|
||
```tsx | ||
romanize('백마'); // 'baengma' | ||
romanize('학여울'); // 'hangnyeoul' | ||
romanize('해돋이'); // 'haedoji' | ||
romanize('좋고'); // 'joko' | ||
romanize('압구정'); // 'apgujeong' | ||
romanize('구미'); // 'gumi' | ||
romanize('대관령'); // 'daegwallyeong' | ||
romanize('ㄱ'); // 'g' | ||
romanize('한국어!'); // 'hangugeo!' | ||
romanize('안녕하세요'); // 'annyeonghaseyo' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
title: romanize | ||
--- | ||
|
||
# romanize | ||
|
||
한글 문자열을 로마자로 변경합니다. | ||
|
||
자세한 예시는 아래 Example을 참고하세요. | ||
|
||
```typescript | ||
function romanize(hangul: string): string; | ||
``` | ||
|
||
## Examples | ||
|
||
```tsx | ||
romanize('백마'); // 'baengma' | ||
romanize('학여울'); // 'hangnyeoul' | ||
romanize('해돋이'); // 'haedoji' | ||
romanize('좋고'); // 'joko' | ||
romanize('압구정'); // 'apgujeong' | ||
romanize('구미'); // 'gumi' | ||
romanize('대관령'); // 'daegwallyeong' | ||
romanize('ㄱ'); // 'g' | ||
romanize('한국어!'); // 'hangugeo!' | ||
romanize('안녕하세요'); // 'annyeonghaseyo' | ||
``` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: standardizePronunciation | ||
--- | ||
|
||
# standardizePronunciation | ||
|
||
Change the Hangul string to standard pronunciation. | ||
|
||
For detailed examples, see below. | ||
|
||
```typescript | ||
function standardizePronunciation( | ||
// Input a Hangul string | ||
hangul: string, | ||
options: { | ||
// Set whether to apply hard sounds. Default is true." | ||
hardConversion: boolean; | ||
} = { hardConversion: true } | ||
): string; | ||
``` | ||
|
||
## Examples | ||
|
||
```tsx | ||
standardizePronunciation('디귿이'); // '디그시' | ||
standardizePronunciation('굳이'); // '구지' | ||
standardizePronunciation('담요'); // '딤뇨' | ||
standardizePronunciation('침략'); // '침냑' | ||
standardizePronunciation('먹는'); // '멍는' | ||
standardizePronunciation('신라'); // '실라' | ||
standardizePronunciation('놓고'); // '노코' | ||
standardizePronunciation('곧이듣다'); // '고지듣따' | ||
standardizePronunciation('곧이듣다', { hardConversion: false }); // '고지듣다' | ||
standardizePronunciation('닦다'); // '닥따' | ||
standardizePronunciation('닦다', { hardConversion: false }); // '닥다' | ||
standardizePronunciation('있다'); // '읻따' | ||
standardizePronunciation('있다', { hardConversion: false }); // '읻다' | ||
standardizePronunciation('핥다'); // '할따' | ||
standardizePronunciation('핥다', { hardConversion: false }); // '할다' | ||
standardizePronunciation('젊다'); // '점따' | ||
standardizePronunciation('젊다', { hardConversion: false }); // '점다' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: standardizePronunciation | ||
--- | ||
|
||
# standardizePronunciation | ||
|
||
한글 문자열을 표준 발음법으로 변경합니다. | ||
|
||
자세한 예시는 아래 Example을 참고하세요. | ||
|
||
```typescript | ||
function standardizePronunciation( | ||
// 한글 문자열을 입력합니다. | ||
hangul: string, | ||
options: { | ||
// 경음화 등의 된소리를 적용할지 여부를 설정합니다. 기본값은 true입니다. | ||
hardConversion: boolean; | ||
} = { hardConversion: true } | ||
): string; | ||
``` | ||
|
||
## Examples | ||
|
||
```tsx | ||
standardizePronunciation('디귿이'); // '디그시' | ||
standardizePronunciation('굳이'); // '구지' | ||
standardizePronunciation('담요'); // '딤뇨' | ||
standardizePronunciation('침략'); // '침냑' | ||
standardizePronunciation('먹는'); // '멍는' | ||
standardizePronunciation('신라'); // '실라' | ||
standardizePronunciation('놓고'); // '노코' | ||
standardizePronunciation('곧이듣다'); // '고지듣따' | ||
standardizePronunciation('곧이듣다', { hardConversion: false }); // '고지듣다' | ||
standardizePronunciation('닦다'); // '닥따' | ||
standardizePronunciation('닦다', { hardConversion: false }); // '닥다' | ||
standardizePronunciation('있다'); // '읻따' | ||
standardizePronunciation('있다', { hardConversion: false }); // '읻다' | ||
standardizePronunciation('핥다'); // '할따' | ||
standardizePronunciation('핥다', { hardConversion: false }); // '할다' | ||
standardizePronunciation('젊다'); // '점따' | ||
standardizePronunciation('젊다', { hardConversion: false }); // '점다' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { romanize } from './romanize'; | ||
|
||
describe('romanize', () => { | ||
it('자음 사이에서 동화 작용이 일어나는 경우', () => { | ||
expect(romanize('백마')).toBe('baengma'); | ||
expect(romanize('종로')).toBe('jongno'); | ||
expect(romanize('왕십리')).toBe('wangsimni'); | ||
expect(romanize('별래')).toBe('byeollae'); | ||
expect(romanize('신라')).toBe('silla'); | ||
}); | ||
|
||
it('ㄴ, ㄹ’이 덧나는 경우', () => { | ||
expect(romanize('학여울')).toBe('hangnyeoul'); | ||
expect(romanize('알약')).toBe('allyak'); | ||
}); | ||
|
||
it('구개음화가 되는 경우', () => { | ||
expect(romanize('해돋이')).toBe('haedoji'); | ||
expect(romanize('같이')).toBe('gachi'); | ||
expect(romanize('굳히다')).toBe('guchida'); | ||
}); | ||
|
||
it('"ㄱ, ㄷ, ㅂ, ㅈ"이 "ㅎ"과 합하여 거센소리로 소리 나는 경우', () => { | ||
expect(romanize('좋고')).toBe('joko'); | ||
expect(romanize('놓다')).toBe('nota'); | ||
expect(romanize('잡혀')).toBe('japyeo'); | ||
expect(romanize('낳지')).toBe('nachi'); | ||
}); | ||
|
||
it('된소리되기는 표기에 반영하지 않는다', () => { | ||
expect(romanize('압구정')).toBe('apgujeong'); | ||
expect(romanize('낙동강')).toBe('nakdonggang'); | ||
expect(romanize('죽변')).toBe('jukbyeon'); | ||
expect(romanize('낙성대')).toBe('nakseongdae'); | ||
expect(romanize('합정')).toBe('hapjeong'); | ||
expect(romanize('팔당')).toBe('paldang'); | ||
expect(romanize('샛별')).toBe('saetbyeol'); | ||
expect(romanize('울산')).toBe('ulsan'); | ||
}); | ||
|
||
it('"ㄱ, ㄷ, ㅂ"은 모음 앞에서는 "g, d, b"로, 자음 앞이나 어말에서는 "k, t, p"로 적는다', () => { | ||
expect(romanize('구미')).toBe('gumi'); | ||
expect(romanize('영동')).toBe('yeongdong'); | ||
expect(romanize('백암')).toBe('baegam'); | ||
expect(romanize('옥천')).toBe('okcheon'); | ||
expect(romanize('합덕')).toBe('hapdeok'); | ||
expect(romanize('호법')).toBe('hobeop'); | ||
expect(romanize('월곶')).toBe('wolgot'); | ||
expect(romanize('벚꽃')).toBe('beotkkot'); | ||
expect(romanize('한밭')).toBe('hanbat'); | ||
}); | ||
|
||
it('"ㄹ"은 모음 앞에서는 "r"로, 자음 앞이나 어말에서는 "l"로 적는다. 단, "ㄹㄹ"은 "ll"로 적는다', () => { | ||
expect(romanize('구리')).toBe('guri'); | ||
expect(romanize('설악')).toBe('seorak'); | ||
expect(romanize('칠곡')).toBe('chilgok'); | ||
expect(romanize('임실')).toBe('imsil'); | ||
expect(romanize('울릉')).toBe('ulleung'); | ||
expect(romanize('대관령')).toBe('daegwallyeong'); | ||
}); | ||
|
||
it('완성된 음절이 아닌 경우에는 그대로 반환한다', () => { | ||
expect(romanize('ㄱ')).toBe('g'); | ||
expect(romanize('가나다라ㅁㅂㅅㅇ')).toBe('ganadarambs'); | ||
expect(romanize('ㅏ')).toBe('a'); | ||
expect(romanize('ㅘ')).toBe('wa'); | ||
}); | ||
|
||
it('특수문자는 로마자 표기로 변경하지 않는다', () => { | ||
expect(romanize('안녕하세요')).toBe('annyeonghaseyo'); | ||
expect(romanize('한국어!')).toBe('hangugeo!'); | ||
expect(romanize('')).toBe(''); | ||
expect(romanize('!?/')).toBe('!?/'); | ||
}); | ||
|
||
it('한글과 영어가 혼합된 경우에는 영어는 그대로 반환된다', () => { | ||
expect(romanize('안녕하세요 es-hangul')).toBe('annyeonghaseyo es-hangul'); | ||
expect(romanize('한국은korea')).toBe('hangugeunkorea'); | ||
expect(romanize('고양이는cat')).toBe('goyangineuncat'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.