2021-10-25から1日間の記事一覧

言語処理100本ノック 第1章 03 文の各単語の長さを求める Python 複数の文字の置換 スペースで区切る mapでlen

nlp100.github.io import re s = 'Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.' # ',' と '.' を削除する s_sub = re.sub('[,.]', '', s) print(s_sub) # スペースで区切って、単語のリストを得る s_s…