import pandas as pd
df = pd.read_csv("인공지능_블로그_감성분석결과.csv")
print(df[['제목', '감성']].head())
출력 예시
제목 감성
AI가 바꾸는 미래 사회 긍정
챗GPT 사용법 정리 중립
일자리를 위협하는 인공지능 기술 부정
4. 긍정 감성 텍스트만 필터링
positive_titles = df[df['감성'] == '긍정']['제목'].dropna().tolist()
print(f"긍정 뉴스 수: {len(positive_titles)}")
5. 형태소 분석 + 명사 추출
from konlpy.tag import Okt
from collections import Counter
okt = Okt()
stopwords = ['인공지능', 'AI', '챗GPT', '사용', '관련', '방법', '정리', '소개', '기술']
def get_nouns_from_text(text_list):
all_nouns = []
for title in text_list:
nouns = okt.nouns(title)
filtered = [word for word in nouns if len(word) > 1 and word not in stopwords]
all_nouns.extend(filtered)
return all_nouns
nouns = get_nouns_from_text(positive_titles)
print("예시 명사 10개:", nouns[:10])