June 2023
Intermediate to advanced
316 pages
4h 31m
Japanese
1 #!/usr/bin/env python 2 import sys, re, operator, collections 3 4 class WordFrequenciesModel: 5 """ データをモデル化する。 6 ここでは、最終結果として単語とその頻度にのみに関心を持つ。""" 7 freqs = {} 8 stopwords = set(open('../stop_words.txt').read().split(',')) 9 def __init__(self, path_to_file): 10 self.update(path_to_file) 11 12 def update(self, path_to_file): 13 try: 14 words = re.findall(r'[a-z]{2,}', open(path_to_file).read().lower()) 15 self.freqs = collections.Counter(w ...
Read now
Unlock full access