June 2023
Intermediate to advanced
316 pages
4h 31m
Japanese
[†1] パイプラインスタイルの変形で、パイプラインスタイルよりも多くの制約がある。
1 #!/usr/bin/env python 2 import sys, re, operator, string 3 4 # 5 # The functions 6 # 7 def read_file(path_to_file, func): 8 with open(path_to_file) as f: 9 data = f.read() 10 func(data, normalize) 11 12 def filter_chars(str_data, func): 13 pattern = re.compile(r'[\W_]+') 14 func(pattern.sub(' ', str_data), scan) 15 16 def normalize(str_data, func): 17 func(str_data.lower(), remove_stop_words) 18 19 def scan(str_data, ...
Read now
Unlock full access