June 2023
Intermediate to advanced
316 pages
4h 31m
Japanese
1 #!/usr/bin/env python 2 import sys, re, operator, string, time 3 4 # 5 # 関数定義 6 # 7 def extract_words(path_to_file): 8 with open(path_to_file) as f: 9 str_data = f.read() 10 pattern = re.compile(r'[\W_]+') 11 word_list = pattern.sub(' ', str_data).lower().split() 12 with open('../stop_words.txt') as f: 13 stop_words = f.read().split(',') 14 stop_words.extend(list(string.ascii_lowercase)) 15 return [w for w in word_list if w not in stop_words] 16 17 def frequencies(word_list): ...
Read now
Unlock full access