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: 특수문자 제거 시 분해된 한글이 제거되지 않도록 수정 #757

Conversation

Jiwon-Woo
Copy link
Member

개요

작업 사항

변경점

목적

스크린샷 (optional)

@Jiwon-Woo Jiwon-Woo added the blocked 다른 PR에 의존중 label Sep 6, 2023
@Jiwon-Woo Jiwon-Woo self-assigned this Sep 6, 2023
@Jiwon-Woo Jiwon-Woo temporarily deployed to development September 6, 2023 17:07 — with GitHub Actions Inactive
@Jiwon-Woo Jiwon-Woo added bug Something isn't working and removed blocked 다른 PR에 의존중 labels Sep 6, 2023
@Jiwon-Woo Jiwon-Woo temporarily deployed to development September 6, 2023 17:20 — with GitHub Actions Inactive
@Jiwon-Woo Jiwon-Woo temporarily deployed to development September 6, 2023 17:46 — with GitHub Actions Inactive
Copy link
Member

@Jake1152 Jake1152 left a comment

Choose a reason for hiding this comment

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

자음, 모음도 정규표현식으로 처리해주신 것 잘 보았습니다
LGTM

Copy link
Member

@scarf005 scarf005 left a comment

Choose a reason for hiding this comment

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

나중에 다양한 입력에 대응할 수 있게 테스트를 추가하면 좋을 것 같네요

@Jiwon-Woo Jiwon-Woo temporarily deployed to development September 7, 2023 00:46 — with GitHub Actions Inactive
@Jiwon-Woo Jiwon-Woo changed the title fix: 자모 분해하기 전 특수문자 제거 fix: 특수문자 제거 시 분해된 한글이 제거되지 않도록 수정 Sep 7, 2023
@Jiwon-Woo Jiwon-Woo merged commit df27363 into develop Sep 7, 2023
5 checks passed
@scarf005
Copy link
Member

scarf005 commented Sep 7, 2023

@Jiwon-Woo 추후 발생할 수 있는 오류를 잡기 위해, 어떤 상황에서 어떤 오류가 나타났는지 예시를 적어주실수 있을까요? (#738, #742, #745, #752, #757)

예)

입력: C++ 입ㅁ
예상: C 입ㅁ
실제: C 입

@scarf005 scarf005 deleted the 756-특수-문자-제거시-자모-분리한-버전도-제거되는-버그 branch September 7, 2023 01:00
@Jiwon-Woo
Copy link
Member Author

Jiwon-Woo commented Sep 7, 2023

@Jiwon-Woo 추후 발생할 수 있는 오류를 잡기 위해, 어떤 상황에서 어떤 오류가 나타났는지 예시를 적어주실수 있을까요? (#738, #742, #745, #752, #757)

예)

입력: C++ 입ㅁ
예상: C 입ㅁ
실제: C 입

특수 문자 사용

  1. 일부 특수 문자 사용시 full-text search에서 sql 문법 에러
    ex) ~, @, *, -, +, -, 짝이 안맞는 소괄호 등
  2. 짝이 안맞는 홑따옴표 사용시 (') LIKE에서 sql 문법 에러

한글 검색어

현재 자모 분리 검색과 초성 검색을 위해 한글 검색어를 분해한 후 DB를 조회하고 있습니다. ex) '파이썬' -> 'ㅍㅏㅇㅣㅆㅓㄴ'
위의 1, 2번 오류를 해결하기 위해 분해한 검색어에 특수문자를 제거하는 함수를 적용했더니 분해된 한글까지 지워버리는 경우가 생겼습니다.
이는 제가 정규표현식에 빠뜨린 부분이 있어서 생긴일이고, 정규표현식 수정해서 해결했습니다.
regex = /[^a-zA-Z0-9가-힣\s]/g -> regex = /[^a-zA-Z0-9가-힣ㄱ-ㅎㅏ-ㅣ\s]/

입력: 'ㅍㅏㅇㅣㅆㅓㄴ'
예상: 'ㅍㅏㅇㅣㅆㅓㄴ'
실제: ''

공백을 포함한 검색어

full-text를 적용해놓아서 공백이 있는 검색어 입력시 공백 기준으로 검색어를 쪼개어서 검색이 가능합니다. 쪼개진 검색어를 하나라도 포함하고 있으면 검색결과에 걸리는데, 만약 공백을 포함한 검색어 결과가 예상과 다르면 full-text 서치가 동작하지 않는 것일 수도 있습니다.
ex) '자바 스크립트' -> 도서명, 저자, 출판사에 '자바' 혹은 '스크립트'를 포함하고 있는 책 반환
'김영한 자바' -> 도서명, 저자, 출판사에 '김영한' 혹은 '자바'를 포함하고 있는 책 반환

예외 케이스 검색어

그래서 지금까지 파악한 예외 검색어는 다음과 같습니다.

  1. 특수 문자 포함 검색어
    ex) 'c++', 'c#', '(2021 시나공' 등
  2. 한글 검색어
  3. 공백을 포함한 검색어
    ex) '자바 스크립트', '김영한 자바 JPA', 'Django Youngjin'

@scarf005
Copy link
Member

scarf005 commented Sep 7, 2023

추가로, - fix #756 과 같이 작성하면 연결된 이슈를 자동으로 닫을 수 있어요

@Jiwon-Woo
Copy link
Member Author

오 감사합니다 지금 올린 풀리퀘에 바로 적용해볼게요

@Jiwon-Woo Jiwon-Woo linked an issue Sep 7, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

특수 문자 제거시 자모 분리한 버전도 제거되는 버그
3 participants