June 2023
Intermediate to advanced
316 pages
4h 31m
Japanese
1 #!/usr/bin/env python 2 import re, sys, operator, queue, threading 3 4 # Two data spaces 5 word_space = queue.Queue() 6 freq_space = queue.Queue() 7 8 stopwords = set(open('../stop_words.txt').read().split(',')) 9 10 # 単語空間の単語を消費し、部分的な結果を頻度空間に送る 11 # ワーカー関数 12 def process_words(): 13 word_freqs = {} 14 while True: 15 try: 16 word = word_space.get(timeout=1) 17 except queue.Empty: 18 break 19 if not word in stopwords: 20 if word in word_freqs: 21 word_freqs[word] += 1 22 else: 23 word_freqs[word] ...
Read now
Unlock full access