Skip to content

Commit

Permalink
fix : getHangulacronym함수를 acronymizeHangul 메서드로 대체합니다. (#148)
Browse files Browse the repository at this point in the history
* Update and rename getHangulAcronym.ts to acronymizeHangul.ts

* Update and rename getHangulAcronym.spec.ts to acronymizeHangul.spec.ts

* Update index.ts

* Update and rename getHangulAcronym.en.mdx to acronymizeHangul.en.mdx

* Update and rename getHangulAcronym.ko.mdx to acronymizeHangul.ko.mdx

* Create odd-squids-sin.md

---------

Co-authored-by: 박찬혁 <[email protected]>
  • Loading branch information
KNU-K and okinawaa committed Jun 29, 2024
1 parent d09822f commit f3c7fe9
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .changeset/odd-squids-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"es-hangul": patch
---

fix : getHangulacronym함수를 acronymizeHangul 메서드로 대체합니다
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# getHangulAcronym
# acronymizeHangul

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(
function acronymizeHangul(
// String consisting of plural nouns (e.g. '버스 충전', '치킨과 맥주')
text: string
hangul: string
): boolean;
```

```typescript
getHangulAcronym('치킨과 맥주').join(''); //치맥
getHangulAcronym('버스 충전 카드').join(''); //버충카
acronymizeHangul('치킨과 맥주').join(''); //치맥
acronymizeHangul('버스 충전 카드').join(''); //버충카
```
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# getHangulAcronym
# acronymizeHangul

한글 문장을 입력받아서, 해당 한글 문장의 첫글자를 리턴해줍니다.
(한글 문장이 아닌, 문장은 취급하지않습니다. 추가로 한글 문장 + 영어 문장의 경우에도 취급하지않습니다.)

```typescript
function getHangulAcronym(
function acronymizeHangul(
// 복수 명사로 이루어진 문자열 (e.g. '버스 충전', '치킨과 맥주')
text: string
hangul: string
): boolean;
```

```typescript
getHangulAcronym('치킨과 맥주').join(''); //치맥
getHangulAcronym('버스 충전 카드').join(''); //버충카
acronymizeHangul('치킨과 맥주').join(''); //치맥
acronymizeHangul('버스 충전 카드').join(''); //버충카
```
18 changes: 18 additions & 0 deletions src/acronymizeHangul.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { acronymizeHangul } from './acronymizeHangul';

describe('acronymizeHangul', () => {
it('한글 문장 단어중 첫 문자만 뽑은 리스트를 반환', () => {
expect(acronymizeHangul('치킨과 맥주')).toHaveLength(2);
expect(acronymizeHangul('치킨과 맥주').join('')).toBe('치맥');

expect(acronymizeHangul('버스 충전 카드')).toHaveLength(3);
expect(acronymizeHangul('버스 충전 카드').join('')).toBe('버충카');
});
it('한글이 아닌 문장 넣었을 때', () => {
expect(() => acronymizeHangul('test test')).toThrowError('"test test" is not a valid hangul string');
});

it('한글과 영어가 섞인 문장을 넣었을 때', () => {
expect(() => acronymizeHangul('고기와 Cheese')).toThrowError('"고기와 Cheese" is not a valid hangul string');
});
});
2 changes: 1 addition & 1 deletion src/getHangulAcronym.ts → src/acronymizeHangul.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import { parseHangul } from './_internal/hangul';
* 한글 문장을 입력받아서, 해당 한글 문장의 초성을을 리턴해줍니다.
* 한글 문장이 아닌, 문장은 취급하지않습니다. 추가로 한글 문장 + 영어 문장의 경우에도 취급하지않습니다.
*/
export function getHangulAcronym(hangul: string) {
export function acronymizeHangul(hangul: string) {
return parseHangul(hangul).split(' ').map(word => word.charAt(0));
}
18 changes: 0 additions & 18 deletions src/getHangulAcronym.spec.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export * from './josa';
export * from './removeLastHangulCharacter';
export * from './utils';
export * from './extractHangul';
export * from './getHangulAcronym';
export * from './acronymizeHangul';

0 comments on commit f3c7fe9

Please sign in to comment.