概要
Volume0-0029 English Sentence
コード
from collections import Counter
def ret_words(str):
ss = str.split(" ")
cs = Counter(ss)
ls = {w: len(w) for w in ss}
return [cs, ls]
def hoge(*args):
ret = []
for arg in args:
print(arg)
ret.append(ret_words(arg))
return ret
print(hoge(
"Thank you for your mail and your lectures"
))
実行結果
Thank you for your mail and your lectures
[[Counter({'your': 2, 'Thank': 1, 'you': 1, 'for': 1, 'mail': 1, 'and': 1, 'lectures': 1}), {'Thank': 5, 'you': 3, 'for': 3, 'your': 4, 'mail': 4, 'and': 3, 'lectures': 8}]]