June 2023
Intermediate to advanced
316 pages
4h 31m
Japanese
1 #!/usr/bin/env python 2 import sys, re, operator, string 3 from functools import reduce 4 # 5 # マップ、リデュースのワーカー関数 6 # 7 def partition(data_str, nlines): 8 """ 9 入力されたdata_str(大きな文字列)を 10 nlines行ごとのブロックに分割する 11 """ 12 lines = data_str.split('\n') 13 for i in range(0, len(lines), nlines): 14 yield '\n'.join(lines[i : i + nlines]) 15 16 def split_words(data_str): 17 """ 18 文字列を受け取り、その中の単語それぞれに対して 19 次の形式の(単語, 1)組のリストを返す 20 [(w1, 1), (w2, 1), ..., (wn, 1)] 21 """ 22 def _scan(str_data): ...
Read now
Unlock full access