from collections import Counterfrom natto import MeCabdef analyze_japanese_text(file_path): # MeCab 인스턴스 mecab = MeCab() # 텍스트 파일 with open(file_path, 'r', encoding='utf-8') as file: text = file.read() # 텍스트를 토큰화하여 단어 추출하기 tokens = [] for n in mecab.parse(text, as_nodes=True): if n.is_nor(): tokens.append(n.surface) # 단어별 사용빈도 계산 word_freq = Counter(tokens) return word_freqdef main(): file_path = "/Users/***/Desktop/venv2/book_text.txt word_freq = analyze_japanese_text(file_path) # 사용빈도가 높은 순으로 정렬하여 출력 for word, freq in word_freq.most_common(): print(f"{word}: {freq}")if __name__ == "__main__": main()
왜 자꾸 ImportError: cannot import name 'escape' from 'cgi' 이게 뜨는건가요
왜 자꾸 ImportError: cannot import name 'escape' from 'cgi' 이게 뜨는건가요
댓글 0