-
Notifications
You must be signed in to change notification settings - Fork 0
[1차] 뉴스 클러스터링 #33
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
base: main
Are you sure you want to change the base?
[1차] 뉴스 클러스터링 #33
Conversation
Summary of ChangesHello @dongglehada, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 '뉴스 클러스터링' 문제에 대한 Swift 솔루션을 도입합니다. 이 솔루션은 두 개의 입력 문자열을 처리하여 두 글자 단어 쌍(빅그램)을 추출하고, 이들의 다중집합 교집합과 합집합을 계산한 다음, 이 계산된 수를 기반으로 유사도 지수를 산출합니다. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
제출하신 [1차] 뉴스 클러스터링 문제 풀이 코드를 검토했습니다. makeWordList 함수를 통해 두 글자씩 끊어 단어 리스트와 개수를 효율적으로 생성하고, 이를 바탕으로 자카드 유사도를 계산하는 방식이 명확하고 잘 구현되었습니다. 특히, 두 집합이 모두 공집합일 경우 65536을 반환하는 예외 처리도 문제의 요구사항에 맞게 잘 처리되었습니다. 전반적으로 깔끔하고 이해하기 쉬운 코드입니다. 몇 가지 가독성 및 유지보수성 측면에서 개선할 수 있는 부분을 제안합니다.
| return 65536 | ||
| } | ||
| return 65536 * intersection / union |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return 65536 * intersection / union | ||
| } | ||
|
|
||
| func makeWordList(_ str: String) -> ([String: Int], Int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var str1 = makeWordList(str1) | ||
| var str2 = makeWordList(str2) | ||
| var intersection: Int = 0 | ||
| for key in str1.0.keys { | ||
| let num = min(str1.0[key] ?? 0, str2.0[key] ?? 0) | ||
| intersection += num | ||
| } | ||
| let union = str1.1 + str2.1 - intersection | ||
|
|
||
| if str1.1 == 0 && str2.1 == 0 { | ||
| return 65536 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makeWordList 함수에서 반환하는 튜플의 요소에 이름을 부여하면 코드의 가독성을 크게 향상시킬 수 있습니다. 또한, str1과 str2 매개변수를 섀도잉하는 대신, 튜플을 직접 구조 분해하여 명확한 변수 이름을 사용하는 것이 좋습니다.
| var str1 = makeWordList(str1) | |
| var str2 = makeWordList(str2) | |
| var intersection: Int = 0 | |
| for key in str1.0.keys { | |
| let num = min(str1.0[key] ?? 0, str2.0[key] ?? 0) | |
| intersection += num | |
| } | |
| let union = str1.1 + str2.1 - intersection | |
| if str1.1 == 0 && str2.1 == 0 { | |
| return 65536 | |
| let (str1Map, str1Count) = makeWordList(str1) | |
| let (str2Map, str2Count) = makeWordList(str2) | |
| var intersection: Int = 0 | |
| for key in str1Map.keys { | |
| let num = min(str1Map[key] ?? 0, str2Map[key] ?? 0) | |
| intersection += num | |
| } | |
| let union = str1Count + str2Count - intersection | |
| if str1Count == 0 && str2Count == 0 { | |
| return 65536 |
🔗 문제 링크
✔️ 소요된 시간
70분
📚 새롭게 알게된 내용