from konlpy.tag import Okt
from collections import Counter
okt = Okt()
stopwords = ['인공지능', 'AI', '챗GPT', '관련', '소개', '활용', '사용', '방법', '정리', '이해']
def extract_keywords(text):
nouns = okt.nouns(text)
words = [word for word in nouns if len(word) > 1 and word not in stopwords]
return Counter(words)
6. 긍정/부정 키워드 추출
pos_words = extract_keywords(pos_texts)
neg_words = extract_keywords(neg_texts)
print("긍정 키워드 Top 10:", pos_words.most_common(10))
print("부정 키워드 Top 10:", neg_words.most_common(10))
긍정 키워드 Top 10: [('미래', 5), ('기대', 4), ('도움', 3), ('변화', 3), ('기술', 3), ...]
부정 키워드 Top 10: [('위협', 4), ('문제', 3), ('불안', 3), ('일자리', 2), ('혼란', 2), ...]