아직 완벽하지 않지만 제목, 작성자, 링크, 내용 크롤링은 전부 가능하고 버튼 연동만 해주면 된다.
이런식으로 크롤링된다.
def extract_word(text):
hangul = re.compile('[^가-힣]')
result = hangul.sub(' ', text)
return result
특수문자 제거하기
spacing = Spacing()
!pip install git+https://github.com/haven-jeon/PyKoSpacing.git
다운 받고 띄어쓰기되어 있지 않은 문자열들을 전부 해준다.
완벽하게 되진 않음..
okt = Okt()
words = " ".join(df['content'].tolist())
words = okt.morphs(words,stem=True)
remove_one_word = [x for x in words if len(x)>1 or x in ["옷", '킹', '굿', '형', '팔', '면', '티', '목']]
len(remove_one_word)
bul_url = 'data/stopwords.txt'
with open(bul_url, 'r', encoding='cp949') as f:
list_file = f.readlines()
stopwords = list_file[0].split(",")
remove_stopwords = [x for x in remove_one_word if x not in stopwords]
len(remove_stopwords)
minimum_count = 3
more_than_one_time= []
for i in tqdm(range(len(remove_stopwords))):
tmp = remove_stopwords[i]
if (remove_stopwords.count(tmp) >= minimum_count) & (len(tmp) > 2):
more_than_one_time.append(tmp)
c = Counter(more_than_one_time)
wc = WordCloud(font_path='NanumBarunGothic', width=400, height=400, scale=2.0, max_font_size=250)
gen = wc.generate_from_frequencies(c)
plt.figure(figsize=(10, 10))
plt.imshow(gen)
728x90
'AI > 데이터 분석' 카테고리의 다른 글
Bag of Words (BoW)란 ? (0) | 2024.02.24 |
---|---|
[DACON] 따릉이 데이터 분석 EDA (0) | 2022.11.29 |