June 2023
Intermediate to advanced
316 pages
4h 31m
Japanese
1 #!/usr/bin/env python 2 import sys, operator, string 3 4 def characters(filename): 5 for line in open(filename): 6 for c in line: 7 yield c 8 9 def all_words(filename): 10 start_char = True 11 for c in characters(filename): 12 if start_char == True: 13 word = "" 14 if c.isalnum(): 15 # 単語の先頭を発見 16 word = c.lower() 17 start_char = False 18 else: pass 19 else: 20 if c.isalnum(): 21 word += c.lower() 22 else: 23 # 単語の末尾を発見したので送出する 24 start_char = True 25 yield word 26 27 def non_stop_words(filename): 28 stopwords ...
Read now
Unlock full access