Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : getHangulacronym함수를 acronymizeHangul 메서드로 대체합니다. #148

Merged
merged 6 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';