-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: 일관된 한글 표기법 적용 * fix: 기존의 함수를 유지한 채, deprecated 되도록 수정 * fix: main 브랜치와 merge를 위한 수정 * fix: conflict 수정 * fix: 문서에는 chosung prefix를 사용하도록 수정 * fix: ChoseongIncludesDemo 함수명 수정 * chore: cspell.json 으로 설정을 변경합니다. (#172) * fix: 일관된 한글 표기법 적용 * fix: 기존의 함수를 유지한 채, deprecated 되도록 수정 * docs: chosung~ 문서 작성 * fix: choseongIncludes의 인덱싱 처리 * Create fifty-wolves-melt.md * fix: import CI 오류 해결 --------- Co-authored-by: Minsoo Kim <[email protected]> Co-authored-by: 박찬혁 <[email protected]>
- Loading branch information
1 parent
135e419
commit 6160363
Showing
22 changed files
with
298 additions
and
123 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 | ||
--- | ||
|
||
fix: chosung => choseong으로 변환하는 규칙을 적용합니다 |
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
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,27 @@ | ||
import { ChoseongIncludesDemo } from '@/components/demo/chosung-includes-demo'; | ||
|
||
# choseongIncludes | ||
|
||
Performs a search for matches in the initial consonants of a string. | ||
|
||
```typescript | ||
function choseongIncludes( | ||
// The string to be checked for matching initial consonants (e.g., '프론트엔드') | ||
x: string, | ||
// Initial consonant string (e.g., 'ㅍㄹㅌㅇㄷ') | ||
y: string | ||
): boolean; | ||
``` | ||
|
||
```typescript | ||
choseongIncludes('프론트엔드', 'ㅍㄹㅌ'); // true | ||
choseongIncludes('00프론트엔드', 'ㅍㄹㅌ'); // true | ||
choseongIncludes('프론트엔드', 'ㅍㅌ'); // false | ||
choseongIncludes('프론트엔드', '푸롴트'); // false | ||
``` | ||
|
||
## Demo | ||
|
||
<br /> | ||
|
||
<ChoseongIncludesDemo /> |
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,27 @@ | ||
import { ChoseongIncludesDemo } from '@/components/demo/choseong-includes-demo'; | ||
|
||
# choseongIncludes | ||
|
||
문자열의 초성 일치 검색을 수행합니다. | ||
|
||
```typescript | ||
function choseongIncludes( | ||
// 초성 일치하는지 검사할 문자열 (e.g. '프론트엔드') | ||
x: string, | ||
// 초성 문자열 (e.g. 'ㅍㄹㅌㅇㄷ') | ||
y: string | ||
): boolean; | ||
``` | ||
|
||
```typescript | ||
choseongIncludes('프론트엔드', 'ㅍㄹㅌ'); // true | ||
choseongIncludes('00프론트엔드', 'ㅍㄹㅌ'); // true | ||
choseongIncludes('프론트엔드', 'ㅍㅌ'); // false | ||
choseongIncludes('프론트엔드', '푸롴트'); // false | ||
``` | ||
|
||
## 사용해보기 | ||
|
||
<br /> | ||
|
||
<ChoseongIncludesDemo /> |
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
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
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
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
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 |
---|---|---|
@@ -1,35 +1,35 @@ | ||
import { chosungIncludes } from './chosungIncludes'; | ||
import { choseongIncludes } from './choseongIncludes'; | ||
|
||
describe('chosungIncludes', () => { | ||
describe('choseongIncludes', () => { | ||
describe('초성이 포함되어있다고 판단되는 경우', () => { | ||
it('"ㅍㄹㅌ" 문자열로 "프론트엔드"를 검색하면 true를 반환한다.', () => { | ||
expect(chosungIncludes('프론트엔드', 'ㅍㄹㅌ')).toBe(true); | ||
expect(choseongIncludes('프론트엔드', 'ㅍㄹㅌ')).toBe(true); | ||
}); | ||
|
||
it('"ㅍㄹㅌ" 문자열로 "00프론트엔드"를 검색하면 true를 반환한다.', () => { | ||
expect(chosungIncludes('00프론트엔드', 'ㅍㄹㅌ')).toBe(true); | ||
expect(choseongIncludes('00프론트엔드', 'ㅍㄹㅌ')).toBe(true); | ||
}); | ||
|
||
it('"ㅍㄹㅌㅇㄷㄱㅂㅈ" 문자열로 "프론트엔드 개발자"를 검색하면 true를 반환한다.', () => { | ||
expect(chosungIncludes('프론트엔드 개발자', 'ㅍㄹㅌㅇㄷㄱㅂㅈ')).toBe(true); | ||
expect(choseongIncludes('프론트엔드 개발자', 'ㅍㄹㅌㅇㄷㄱㅂㅈ')).toBe(true); | ||
}); | ||
|
||
it('"ㅍㄹㅌㅇㄷ ㄱㅂㅈ" 문자열로 "프론트엔드 개발자"를 검색하면 true를 반환한다.', () => { | ||
expect(chosungIncludes('프론트엔드 개발자', 'ㅍㄹㅌㅇㄷ ㄱㅂㅈ')).toBe(true); | ||
expect(choseongIncludes('프론트엔드 개발자', 'ㅍㄹㅌㅇㄷ ㄱㅂㅈ')).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('초성이 포함되어있다고 판단되지 않는 경우', () => { | ||
it('"ㅍㅌ" 문자열로 "프론트엔드"를 검색하면 false를 반환한다.', () => { | ||
expect(chosungIncludes('프론트엔드', 'ㅍㅌ')).toBe(false); | ||
expect(choseongIncludes('프론트엔드', 'ㅍㅌ')).toBe(false); | ||
}); | ||
|
||
it('빈 문자열로 "프론트엔드 개발자"를 검색하면 false를 반환한다.', () => { | ||
expect(chosungIncludes('프론트엔드 개발자', ' ')).toBe(false); | ||
expect(choseongIncludes('프론트엔드 개발자', ' ')).toBe(false); | ||
}); | ||
|
||
it('"푸롴트" 문자열로 "프론트엔드"를 검색하면 초성으로만 구성되어 있지 않아 false를 반환한다.', () => { | ||
expect(chosungIncludes('프론트엔드', '푸롴트')).toBe(false); | ||
expect(choseongIncludes('프론트엔드', '푸롴트')).toBe(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,29 @@ | ||
import { disassembleHangulToGroups } from './disassemble'; | ||
import { canBeChoseong, getChoseong } from './utils'; | ||
|
||
export function choseongIncludes(x: string, y: string) { | ||
const trimmedY = y.replace(/\s/g, ''); | ||
|
||
if (!isOnlyChoseong(trimmedY)) { | ||
return false; | ||
} | ||
|
||
const choseongX = getChoseong(x).replace(/\s/g, ''); | ||
const choseongY = trimmedY; | ||
|
||
return choseongX.includes(choseongY); | ||
} | ||
|
||
/* | ||
* @description 문자열이 한글초성으로만 주어진 경우 | ||
*/ | ||
export function isOnlyChoseong(str: string) { | ||
const groups = disassembleHangulToGroups(str); | ||
if (groups.length === 0) { | ||
return false; | ||
} | ||
|
||
return groups.every(disassembled => { | ||
return disassembled.length === 1 && canBeChoseong(disassembled[0]); | ||
}); | ||
} |
Oops, something went wrong.