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.
Browse files
Browse the repository at this point in the history
* feat : 문장의 각 단어 중 첫 문자만 뽑는 함수추가 * test 및 함수 추가 * add : 한글 문장인지 여부 판별 함수 추가 * fix : 한글 문장인지 여부 판별 기저 및 오류 추가 / arg 이름 변경 test 추가 * fix: src/_internal/hangul.ts Co-authored-by: 박찬혁 <pgg6713@gmail.com> * fix : rename function getFirstHangulLetters -> getHangulAcronym * fix : rename function export function isHangulOnly로 변경 * fix : lint error * fix : index에 추가 * chore : doc 추가 * fix : 문서화 한글 영어 바뀐거 바로 변경 * fix : isHangul로 대체 toss#136 으로 * chore : doc수정 * Update docs/src/pages/docs/api/getHangulAcronym.en.mdx Co-authored-by: 박찬혁 <pgg6713@gmail.com> * fix : Update hangul.ts 안쓰는 메소드 삭제 * Update getHangulAcronym.ko.mdx * Update getHangulAcronym.en.mdx * Update src/getHangulAcronym.ts Co-authored-by: 박찬혁 <pgg6713@gmail.com> * Update src/getHangulAcronym.ts Co-authored-by: 박찬혁 <pgg6713@gmail.com> * Update getHangulAcronym.ts * Update getHangulAcronym.spec.ts * Create fair-brooms-drive.md --------- Co-authored-by: 박찬혁 <pgg6713@gmail.com>
- Loading branch information
1 parent
738ad0f
commit e45f860
Showing
6 changed files
with
68 additions
and
0 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,5 @@ | ||
--- | ||
"es-hangul": patch | ||
--- | ||
|
||
feat : 문장의 각 단어 중 첫 문자만 뽑는 extractHangul 함수를 추가합니다. |
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,16 @@ | ||
# getHangulAcronym | ||
|
||
It receives the Korean sentence and returns the first letter of that Korean sentence. | ||
(We don't deal with non-Korean sentences; we don't deal with additional Korean + English sentences.) | ||
|
||
```typescript | ||
function getHangulAcronym( | ||
// String consisting of plural nouns (e.g. '버스 충전', '치킨과 맥주') | ||
text: string | ||
): boolean; | ||
``` | ||
|
||
```typescript | ||
getHangulAcronym('치킨과 맥주').join(''); //치맥 | ||
getHangulAcronym('버스 충전 카드').join(''); //버충카 | ||
``` |
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,16 @@ | ||
# getHangulAcronym | ||
|
||
한글 문장을 입력받아서, 해당 한글 문장의 첫글자를 리턴해줍니다. | ||
(한글 문장이 아닌, 문장은 취급하지않습니다. 추가로 한글 문장 + 영어 문장의 경우에도 취급하지않습니다.) | ||
|
||
```typescript | ||
function getHangulAcronym( | ||
// 복수 명사로 이루어진 문자열 (e.g. '버스 충전', '치킨과 맥주') | ||
text: string | ||
): boolean; | ||
``` | ||
|
||
```typescript | ||
getHangulAcronym('치킨과 맥주').join(''); //치맥 | ||
getHangulAcronym('버스 충전 카드').join(''); //버충카 | ||
``` |
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,18 @@ | ||
import { getHangulAcronym } from './getHangulAcronym'; | ||
|
||
describe('getHangulAcronym', () => { | ||
it('한글 문장 단어중 첫 문자만 뽑은 리스트를 반환', () => { | ||
expect(getHangulAcronym('치킨과 맥주')).toHaveLength(2); | ||
expect(getHangulAcronym('치킨과 맥주').join('')).toBe('치맥'); | ||
|
||
expect(getHangulAcronym('버스 충전 카드')).toHaveLength(3); | ||
expect(getHangulAcronym('버스 충전 카드').join('')).toBe('버충카'); | ||
}); | ||
it('한글이 아닌 문장 넣었을 때', () => { | ||
expect(() => getHangulAcronym('test test')).toThrowError('"test test" is not a valid hangul string'); | ||
}); | ||
|
||
it('한글과 영어가 섞인 문장을 넣었을 때', () => { | ||
expect(() => getHangulAcronym('고기와 Cheese')).toThrowError('"고기와 Cheese" is not a valid hangul string'); | ||
}); | ||
}); |
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,12 @@ | ||
import { parseHangul } from './_internal/hangul'; | ||
|
||
/** | ||
* | ||
* @param getHangulAcronym | ||
* @description | ||
* 한글 문장을 입력받아서, 해당 한글 문장의 초성을을 리턴해줍니다. | ||
* 한글 문장이 아닌, 문장은 취급하지않습니다. 추가로 한글 문장 + 영어 문장의 경우에도 취급하지않습니다. | ||
*/ | ||
export function getHangulAcronym(hangul: string) { | ||
return parseHangul(hangul).split(' ').map(word => word.charAt(0)); | ||
} |
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