Open
Conversation
jhgarry
reviewed
Mar 26, 2025
| "# 리뷰 텍스트 추출\n", | ||
| "################################\n", | ||
| "# reviews_class = \n", | ||
| "reviews_class = soup.find_all(\"p\", class_=[\"context-text\", \"css-c92dc4\"]) # `class_` 속성 사용\n", |
There was a problem hiding this comment.
find_all로 class_ 속성을 받아오는 게 훨씬 더 직관적이어서 좋은 것 같네요. 하나 더 배워갑니다.
| "# 리뷰어 리스트 출력\n", | ||
| "# 각 리뷰 텍스트 정리 후 추가\n", | ||
| "for review in reviews_class:\n", | ||
| "for review, reviewer in zip(reviews_class, reviewers_class) :\n", |
| " count += 1\n", | ||
| "\n", | ||
| "# 마지막 리뷰 처리 (남은 게 있을 경우)\n", | ||
| "if count > 0:\n", |
There was a problem hiding this comment.
if문이 필요한 건가요? 마지막 리뷰에 도달할 때는 count가 항상 5일 것 같아서요.
| " path_tag = container.find(\"path\")\n", | ||
| " if path_tag:\n", | ||
| " d_attr = path_tag['d']\n", | ||
| " star_check = d_attr[1:3] \n", |
There was a problem hiding this comment.
d_attr이랑 star_check 두 줄로 안하고 ['d'][1:3]으로 한줄로 줄일 수도 있을 것 같아요.
| "################################\n", | ||
| "\n", | ||
| "# 각 리뷰별로 별점 계산\n", | ||
| "rating_containers = soup.find_all(\"svg\", attrs={\"xmlns\": \"http://www.w3.org/2000/svg\", \"class\": \"css-1mj121y\"})\n", |
| "\n", | ||
| "# 단어 추출 (특수문자 제거)\n", | ||
| "# words = \n", | ||
| "words = re.sub(r'[^가-힣a-zA-Z0-9\\s]', '', all_reviews_text).split()\n", |
There was a problem hiding this comment.
sub으로 접근하는 방식이나 ^으로 선택 외 다른 것들을 제거하는 방식은 생각해보지 못했었습니다. 배워갑니다.
| "\n", | ||
| "# 불용어 제거\n", | ||
| "# filtered_words = \n", | ||
| "filtered_words = [c for c in words if c not in korean_stopwords]\n", |
There was a problem hiding this comment.
이 방식이 정답이었겠군요, 저는 set을 제대로 활용을 못해 결과가 좋지 않았었습니다. 저는이 부분의 코드를 특히 기억해놔야 할 것 같습니다.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.