June 2023
Intermediate to advanced
316 pages
4h 31m
Japanese
1 #!/usr/bin/env python 2 import sys, re, operator, string 3 4 # 5 # 関数定義 6 # 7 def extract_words(path_to_file): 8 assert(type(path_to_file) is str), "I need a string! I quit!" 9 assert(path_to_file), "I need a non-empty string! I quit!" 10 11 with open(path_to_file) as f: 12 data = f.read() 13 pattern = re.compile(r'[\W_]+') 14 word_list = pattern.sub(' ', data).lower().split() 15 return word_list 16 17 def remove_stop_words(word_list): 18 assert(type(word_list) ...
Read now
Unlock full access