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

feat : 문장의 각 단어 중 첫 문자만 뽑는 함수추가 ( #128 이슈에 대한 ) #133

Merged
merged 26 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c811e8d
feat : 문장의 각 단어 중 첫 문자만 뽑는 함수추가
KNU-K Jun 25, 2024
2b7fbd4
add : 한글 문장인지 여부 판별 함수 추가
KNU-K Jun 28, 2024
cc53591
fix : 한글 문장인지 여부 판별 기저 및 오류 추가 / arg 이름 변경
KNU-K Jun 28, 2024
dcecb15
fix: src/_internal/hangul.ts
KNU-K Jun 29, 2024
b31a5b3
fix : rename function
KNU-K Jun 29, 2024
2e2b134
fix : rename function
KNU-K Jun 29, 2024
ea4cb1b
Merge branch 'main' of https://github.com/KNU-K/es-hangul
KNU-K Jun 29, 2024
83fd467
Merge branch 'main' into main
KNU-K Jun 29, 2024
7bd33ed
fix : lint error
KNU-K Jun 29, 2024
fffd30e
Merge branch 'main' of https://github.com/KNU-K/es-hangul
KNU-K Jun 29, 2024
1d74c1e
fix : index에 추가
KNU-K Jun 29, 2024
e5e7765
chore : doc 추가
KNU-K Jun 29, 2024
9c72739
fix : 문서화 한글 영어 바뀐거 바로 변경
KNU-K Jun 29, 2024
1ba5c31
Merge branch 'main' into main
KNU-K Jun 29, 2024
53544bd
fix : isHangul로 대체 #136 으로
KNU-K Jun 29, 2024
444e217
Merge branch 'main' of https://github.com/KNU-K/es-hangul
KNU-K Jun 29, 2024
4afa4d9
chore : doc수정
KNU-K Jun 29, 2024
8079b7d
Update docs/src/pages/docs/api/getHangulAcronym.en.mdx
KNU-K Jun 29, 2024
e409273
fix : Update hangul.ts
KNU-K Jun 29, 2024
4e4e5bd
Update getHangulAcronym.ko.mdx
KNU-K Jun 29, 2024
c6f1bc4
Update getHangulAcronym.en.mdx
KNU-K Jun 29, 2024
ba3ed2a
Update src/getHangulAcronym.ts
KNU-K Jun 29, 2024
00b3560
Update src/getHangulAcronym.ts
KNU-K Jun 29, 2024
b7dd6a7
Update getHangulAcronym.ts
KNU-K Jun 29, 2024
a36ab58
Update getHangulAcronym.spec.ts
KNU-K Jun 29, 2024
3ffcd89
Create fair-brooms-drive.md
okinawaa Jun 29, 2024
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
16 changes: 16 additions & 0 deletions docs/src/pages/docs/api/getHangulAcronym.en.mdx
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(''); //버충카
```
16 changes: 16 additions & 0 deletions docs/src/pages/docs/api/getHangulAcronym.ko.mdx
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(''); //버충카
```
18 changes: 18 additions & 0 deletions src/getHangulAcronym.spec.ts
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');
});
});
12 changes: 12 additions & 0 deletions src/getHangulAcronym.ts
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));
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './hangulIncludes';
export * from './josa';
export * from './removeLastHangulCharacter';
export * from './utils';
export * from './getHangulAcronym';