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: 영문 알파벳을 qwerty 자판에 매칭되는 한글로 변환하는 함수 추가 #68

Merged
merged 11 commits into from
Apr 23, 2024

Conversation

99mini
Copy link
Contributor

@99mini 99mini commented Apr 19, 2024

Overview

close #60

#60 에서 제안드린 영어 알파벳 자판을 한글 자판으로 바꾸는 함수(convertQwertyToHangulAlphabet)와 영어 알파벳을 온전한 한글 음절로 함성하는 함수(convertQwertyToHangul), QWERTY 영어 알파벳과 한글 음소를 매핑한 상수 변수 (QWERTY_KEYBOARD_MAP)를 추가합니다.

convertQwertyToHangulAlphabet

convertQwertyToHangulAlphabet('abc') // 'ㅁㅠㅊ'
convertQwertyToHangulAlphabet('vm론트') // 'ㅍㅡ론트'

영어 알파벳을 한글 음소로 바꾸는 역할을 수행합니다.

  • 영어 알파벳이 아닌 경우 문자열을 유지합니다.

convertQwertyToHangul

convertQwertyToHangul('abc') // '뮻'
convertQwertyToHangul('vmfhsxmdpsem') // '프론트엔드'

영어 알파벳을 한글로 합성하는 역할을 수행합니다.

QWERTY_KEYBOARD_MAP

/**
 * qwerty 키보드 자판의 대소문자를 구분한 영어 알파벳을 
 * 한글 음소와 맵핑한 객체
 */
export const QWERTY_KEYBOARD_MAP = {
  q: 'ㅂ',
  Q: 'ㅃ',
  w: 'ㅈ',
  W: 'ㅉ',
  ...
}

PR Checklist

  • I read and included theses actions below
  1. I have read the Contributing Guide
  2. I have written documents and tests, if needed.

Copy link

vercel bot commented Apr 19, 2024

Someone is attempting to deploy a commit to the Toss Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

changeset-bot bot commented Apr 19, 2024

🦋 Changeset detected

Latest commit: 32731ae

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@99mini 99mini changed the title Feat: convertAlphabetToHangul 함수 추가합니다. feat: convertAlphabetToHangul 함수 추가합니다. Apr 19, 2024
@99mini 99mini changed the title feat: convertAlphabetToHangul 함수 추가합니다. feat: convertAlphabetToHangul 함수와 KEYBOARD_MAP 상수를 추가합니다. Apr 19, 2024
* @param 한글로 변환하고자 하는 영문
* @returns 한글 자모로 분해된 문자열
*/
export function convertAlphabetToHangul(engKeyboardText: string): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alphabet이라는 워딩이 영어를 뜻한다는 것을 대부분 경우에 알겠지만, es-hangul에서는 오해의 소지가 존재할 것 같아요.

#64 PR에서 새롭게 추가된 것들을 포함하여, es-hangul 소스 코드 내에서 hangulAlphabet이라는 워딩을 꽤 사용하고 있는데,
영어 알파벳인 경우는 englishAlphabet으로 더 명시적으로 드러내주는게 오해의 소지가 없지 않을까도 싶네요.
제가 괜한 걱정을 하는 것 같기도해서, 작성자분의 생각도 궁금해요!

나무위키 라서 신빙성이 떨어질 수는 있지만 다음과 같은 문단이 있어요! 저는 알파벳이란, 영어에서만 사용되는 단어인줄 알았는데 전세계에서 통용되는 단어였더라고요

하나의 글자가 하나의 자음 또는 모음을 나타내는 문자 체계. 흔히 알파벳 하면 A,B,C,D,E,F,G,H...를 떠올리는데, 이는 라틴 문자이고 '알파벳'은 전 세계 문자 체계 전체의 분류에서 나온 개념이다.

Copy link
Contributor Author

@99mini 99mini Apr 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위키피디아 - 국문 에서 알파벳을 검색할 때 음소문자로 넘겨주고 있으며 위키피디아 - 영문 에서 알파벳을 영문 알파벳으로 국한하지 않는 것 같아요.

추가적으로 캠브릿지 영어 사전 의 예문에서도 English alphabet 이라는 표현을 사용하는 것으로 보아 okinawaa님께서 제안해주신 englishAlphabet이라고 명시적으로 드러내주는 것이 더 좋을 것 같습니다!

캠브릿지 영어 사전 alphabet
뜻: a set of letters used for writing a language
예문: The English alphabet starts with A and ends with Z.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주로 사용하는 한글 자판과 영문 자판에는 두벌식과 쿼티라는 이름이 있습니다.
문자보다 자판 이름을 써서 convertQwertyToDubeolsik은 어떨까요?

Copy link
Contributor Author

@99mini 99mini Apr 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 좋습니다!
okinawaa님께서 제안주신 englishAlphabet과 hangulAlphabet을구분하자는 의견과 더불어 honnip님의 제안인 두벌식과 쿼티 자판이름을 사용하는 것이 해당 함수에 대한 설명으로 더 좋은 것 같습니다!

Comment on lines 13 to 15
it('한글 글자는 한글 자/모로 바꾼다.', () => {
expect(convertAlphabetToHangul('vm론트')).toBe('ㅍㅡㄹㅗㄴㅌㅡ');
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

한글 글자인 론트가, ㄹㅗㄴㅌㅡ 로 쪼개지는것을 유저가 쉽게 파악할 수 없는 동작방식이라고 생각하는데, 쪼개져야 하는 이유가 궁금해요!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#64 한글을 한 음절로 합치는 assemble 함수가 만들어지기 전에 해당 코드 작업을 해서 그랬던 것 같습니다.

okinawaa님의 의견에 동의하며 convertAlphabetToHangul함수는 온전한 한글 음절 (문장)을 리턴하는 함수가 되는 것이 좋을 것 같습니다!


describe('convertAlphabetToHangul', () => {
it('알파벳을 한글 타자로 바꾼다.', () => {
expect(convertAlphabetToHangul('abc')).toBe('ㅁㅠㅊ');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abc를 타자로 친다면, 이 나올것으로 개발자는 기대할 것이라고 생각하는데 분해된 값이 나와도 괜찮을까요?

convertAlphabetToHangul를 사용하는 실제 상황을 한번 생각해봤어요.
아래 영상과 같은 검색 시스템에서 한국인 유저가 영어인 상태로 타이핑을 했을때, 한글로 변환해서 데이터 처리를 하는 상황이 꽤 있을 것 같은데 어떻게 생각하시나요!?

Screen.Recording.2024-04-21.at.11.46.24.PM.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#64 한글을 한 음절로 합치는 assemble 함수가 만들어지기 전에 해당 코드 작업을 해서 그랬던 것 같습니다.

okinawaa님의 의견에 동의하며 convertAlphabetToHangul함수는 온전한 한글 음절 (문장)을 리턴하는 함수가 되는 것이 좋을 것 같습니다!

음절을 disassemble하지 않는 것과 더불어 이번 pr의 함수는 #64 에서 구현한 assemble 함수를 이용하여 한글로 반환하는 기능을 수행하는 것이 좋을 것 같아요~!

@99mini
Copy link
Contributor Author

99mini commented Apr 21, 2024

@okinawaa 님! 남겨주신 리뷰 감사합니다! 리뷰에 대해서 다시 생각해본 제 의견 아래에 추가적으로 남깁니다.

convertAlphabetToHangul함수의 관심사는 "qwerty 방식의 영어 알파벳을 두벌식 한글로 변환한다" 인 것 같습니다. 따라서 영어 알파벳에서 변환된 한글 자음/모음을 온전한 한글로 합치는 일(#64 에서 진행 중인 assembleHangul함수)과 분리됨이 좋은 것 같습니다.
이와 같은 제 의견으로 위에 남겨주신 리뷰에 대해서 다시 한 번 리뷰 남깁니다.


한글 글자인 론트가, ㄹㅗㄴㅌㅡ 로 쪼개지는것을 유저가 쉽게 파악할 수 없는 동작방식이라고 생각하는데, 쪼개져야 하는 이유가 궁금해요!

쪼개져야할 이유가 없을 것 같습니다! 해당 함수의 관심사에서 벗어나는 일이니 ㅍㅡ론트를 반환하는 것이 옳은 것 같습니다.


abc를 타자로 친다면, 뮻 이 나올것으로 개발자는 기대할 것이라고 생각하는데 분해된 값이 나와도 괜찮을까요?

convertAlphabetToHangul를 사용하는 실제 상황을 한번 생각해봤어요.
아래 영상과 같은 검색 시스템에서 한국인 유저가 영어인 상태로 타이핑을 했을때, 한글로 변환해서 데이터 처리를 하는 상황이 꽤 있을 것 같은데 어떻게 생각하시나요!?

convertAlphabetToHangul 함수의 관심사는 영어 알파벳을 두벌식 한글로 변환하는 것으로 정하고, 리뷰에 남겨주신 유스케이스가 빈번할 것으로 예상되니 convertAlphabetToHangul#64assembleHangul함수를 함께 사용하는 쿼티 자판을 한글로 변환하는 함수를 별도로 선언하는 것이 어떨까 싶습니다!

function 쿼티를_한글로_변환하는_함수(target: string): string {
  return assembleHangul(...convertAlphabetToHangul(target).split(""))
}

@99mini 99mini changed the title feat: convertAlphabetToHangul 함수와 KEYBOARD_MAP 상수를 추가합니다. feat: 영문 알파벳을 qwerty 자판에 매칭되는 한글로 변환하는 함수 추가 Apr 22, 2024
@99mini 99mini requested a review from okinawaa April 22, 2024 15:48
evan-moon
evan-moon previously approved these changes Apr 23, 2024
Copy link
Member

@evan-moon evan-moon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 코멘트들이 모두 훌륭하게 반영된 것을 확인하여 Approve 합니다!
cc. @okinawaa @99mini

@okinawaa okinawaa merged commit 0c784ff into toss:main Apr 23, 2024
1 of 2 checks passed
@github-actions github-actions bot mentioned this pull request Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: 영문 자판을 한글 자판으로 수정하는 함수
4 participants