Notice
Recent Posts
Recent Comments
Links
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Today
In Total
관리 메뉴

A Joyful AI Research Journey🌳😊

[4] 241104 Word Cloud (AI) [Goorm All-In-One Pass! AI Project Master - 4th Session, Day 4] 본문

🌳AI & Quantum Computing Bootcamp✨/Tasks

[4] 241104 Word Cloud (AI) [Goorm All-In-One Pass! AI Project Master - 4th Session, Day 4]

yjyuwisely 2024. 11. 4. 15:53

241104 Mon 4th class

정보를 공유하는 사람은 더 발전한다. 

민감한 주제X 


5-3 실습 1 - 나만의 데이터 셋을 이용해서 워드 클라우드 해보기
5-4 실습 2- 이미지를 바꿔보기
5-5 실습 3 - txt 파일에 불용어 사전 만들어서 이를 불러와서 해 보기
5-6 이미지 변경해서 워드 클라우드 한 코드 및 이미지를 올려보기.


주제 

AI subfields 

South Korea 수출품

AI로 골랐다. 


import matplotlib.font_manager as fm # 폰트 관련 용도
import matplotlib.pyplot as plt # 그래프 그리는 용도
import numpy as np # Import numpy and assign it to the alias 'np'

위키피디아에서 정보를 가져와서 TXT 파일로 저장했다. https://en.wikipedia.org/wiki/Artificial_intelligence

import requests
from bs4 import BeautifulSoup
import re
# Get the webpage content
# 웹 페이지 콘텐츠 가져오기
url = "https://en.wikipedia.org/wiki/Artificial_intelligence"
response = requests.get(url)
# Parse HTML
# HTML 파싱하기
soup = BeautifulSoup(response.content, 'html.parser')
# Remove unwanted elements
# 필요 없는 요소 제거하기
for unwanted in soup.find_all(['script', 'style', 'sup', 'table', 'footer', 'nav']):
unwanted.decompose()
# Extract main content
# 주요 콘텐츠 추출하기
main_content = soup.find(id='mw-content-text')
# Get text and clean it
# 텍스트 추출 및 정리하기
if main_content:
text = main_content.get_text()
# Clean the text
# 텍스트 정리하기
text = re.sub(r'\[.*?\]', '', text) # Remove citations [1], [2], etc.
# 각주 제거 [1], [2] 등
text = re.sub(r'\n+', '\n', text) # Remove multiple newlines
# 여러 개의 줄바꿈 문자 제거
text = re.sub(r'\s+', ' ', text) # Remove multiple spaces
# 여러 개의 공백 제거
# Save to file
# 파일로 저장하기
with open('ai_wiki.txt', 'w', encoding='utf-8') as f:
f.write(text)
print("Text has been saved to ai_wiki.txt") # 파일 저장 완료 메시지 출력

https://github.com/yjyuwisely/AI_project_mastery_bootcamp/blob/main/AI_Word_Cloud.ipynb

 

AI_project_mastery_bootcamp/AI_Word_Cloud.ipynb at main · yjyuwisely/AI_project_mastery_bootcamp

Contribute to yjyuwisely/AI_project_mastery_bootcamp development by creating an account on GitHub.

github.com


완성본)


https://codehome.tistory.com/9

 

1. 코랩(colab) 시작하기 (환경 설정)

파이썬등의 프로그램을 설치하고 환경을 구축하는 것은 프로그래밍 입문자에겐 만만치 않은 작업이지요! 코랩은 파이썬을 설치하거나 환경 구축을 하지 않아도 클라우드 환경에서 자유롭게 파

codehome.tistory.com

728x90
반응형
Comments