단어 빈도 분석기
텍스트를 분석하여 각 단어의 출현 빈도를 순위별로 표시합니다.
단어 빈도 계산기는 텍스트 블록을 분석하여 각 단어가 얼마나 자주 나타나는지 가장 많은 것부터 적은 것 순으로 알려줍니다. 문서의 어휘 분포를 이해하거나, 과도하게 사용된 단어를 찾거나, 전문 소프트웨어 없이 기본 텍스트 분석을 수행해야 하는 작가, 편집자, 학생, 데이터 분석가에게 유용한 도구입니다.
텍스트를 붙여넣으면 도구가 개별 단어로 토큰화하고, 대소문자를 정규화하여("The", "the", "THE"는 같은 단어로 계산) 빈도 표를 표시합니다. 일반 불용어를 필터링하여 의미 있는 내용어에 집중할 수 있습니다.
단어 빈도 분석은 글쓰기를 넘어 다양한 응용이 있습니다: 언어학에서는 가독성 점수의 기반이 되고, 마케팅에서는 고객이 가장 많이 사용하는 용어를 파악하며, SEO에서는 콘텐츠의 자연스러운 키워드 밀도를 파악하는 데 도움이 됩니다.
자주 묻는 질문
코드 구현
from collections import Counter
import re
STOP_WORDS = {
"a", "an", "the", "and", "or", "but", "in", "on", "at", "to",
"for", "of", "with", "by", "from", "is", "are", "was", "were",
"it", "this", "that", "be", "as", "not", "i", "you", "he", "she",
}
def word_frequency(text: str, stop_words: bool = True, top_n: int = 10) -> list[tuple[str, int]]:
# Lowercase and extract words
words = re.findall(r"[a-z']+", text.lower())
if stop_words:
words = [w for w in words if w not in STOP_WORDS]
counter = Counter(words)
return counter.most_common(top_n)
text = """To be or not to be, that is the question.
Whether tis nobler in the mind to suffer
the slings and arrows of outrageous fortune."""
for word, count in word_frequency(text):
print(f"{word:<20} {count}")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.